Fork me on GitHub
#hoplon
<
2016-05-03
>
micha02:05:40

@leontalbot: there is the *request* dynamic var i think

micha02:05:44

one sec i check

micha02:05:27

yep that should work

leontalbot02:05:28

@micha! Excellent! Can you provide a minimal exemple so I can figure out how to use it?

micha02:05:19

could you try putting something like (prn castra.core/*request*) into one of your rpc functions in the server?

micha02:05:30

it should be populated with the request map from ring

micha02:05:20

it will contain the client's ip address and all the other things in the request map

leontalbot02:05:03

(defrpc test! [] (str castra.core/*request*))
(test!)
=> ""
@micha ^^^

leontalbot02:05:20

I must do something wrong...

micha02:05:36

it won't work in the repl

micha02:05:43

because there is no http request there

micha02:05:11

you would need to make a request from the client to have that var be bound

leontalbot02:05:08

@micha You are right! it works, thanks!

leontalbot02:05:30

Castra is a really nice piece of software

micha02:05:50

hopefully documentation soon simple_smile

leontalbot02:05:56

Count me in if you need help simple_smile

micha03:05:15

much appreciated!

levitanong06:05:28

Hi all! Javelin question: Given a large data structure, would a change in a very specific and small part of that structure cause reevaluation for all cells that have that large data structure as a source? For example:

(defc data {:a 2
  :b {:c 3 :d 4}
  :e {:f 5 :g 6}})

(defc= bd (get-in data [:b :d]))
(swap! data assoc-in [:f :g] 7)
In the example above, will the swap cause bd to reevaluate?

dm306:05:07

yes, because data changes

onetom08:05:05

Does anyone actually uses the castra.core/*validate-only* dynamic var? It seems to me it's just some debug helper feature: https://github.com/hoplon/castra/commit/aebc5c37fc8558255c1756c0f6342a5619f84cd0

levitanong08:05:46

@dm3: Wouldn’t that mean that ultimately for large projects, datascript is untenable?

dm308:05:12

define large simple_smile

levitanong08:05:40

@dm3 say… enterprise software 😛

onetom08:05:25

@micha: @jumblerg: would it make sense to hook up the castra xhr responses to some cells earlier, instead of staying in promise land across mkremote, ajax, ajax-fn? we were trying to handle unauthorized responses to castra rpc requests. 1. make rpc call #1 2. it responds with a castra {:error {:message "Unauthorized" :data :unauthorized}} 3. show a login dialog until the user successfully logs in 4. make rpc call #2 (with the same parameters as rpc call #1) 5. return the response of call #2 as the response for call #1 to implement this with promises is quite unreadable and would require to redefine all of castra/core.cljs as i understood.

thedavidmeister09:05:32

@levitanong: i’ve been thinking about this. One idea I had was filtered databases.

thedavidmeister09:05:43

@levitanong: also, there’s nothing to say you can’t have as many databases as you want

thedavidmeister09:05:44

@levitanong: e.g. I’m probably going to have a separate database for “status messages”

thedavidmeister09:05:37

one reason to pass your conn around, so you can re-use utility functions for different dbs

thedavidmeister10:05:41

i haven’t tried this, but a filtered database would change less frequently than the whole db, so if you had queries that you know only applied against a subset of the main db, and they were more expensive than a filter, you could squeeze some efficiency out there

levitanong10:05:25

@thedavidmeister: oooh! that looks like it could be useful. I’ll give it a try one of these days. Thanks for the tip simple_smile

thedavidmeister11:05:36

org.sonatype.aether.resolution.ArtifactResolutionException: Could not find artifact com.datomic:datomic-transactor-pro:jar:0.9.5350 in clojars ()

thedavidmeister11:05:52

running boot datomic -k XYZ

thedavidmeister11:05:21

looks suspicious… i don’t really know anything about maven though

thedavidmeister11:05:51

Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install-file (default-cli) on project standalone-pom: The specified file '/Users/thedavidmeister/estimate-work/datomic-transactor-pro-0.9.5344.jar' not exists -> [Help 1]

levitanong12:05:29

Hmm. I do something different with datomic.

levitanong12:05:50

(let [uri "datomic:"]
  (d/delete-database uri)
  (d/create-database uri)
  (def conn (d/connect uri))
  (d/transact conn schema)
  (sample/init-all! conn))

onetom12:05:52

@thedavidmeister: u probably want to cd /your/datomic-pro/ and bin/maven-install

levitanong12:05:34

oh wait, you’re using pro

levitanong12:05:38

this is the free version

thedavidmeister12:05:08

i can do either...

onetom12:05:12

if thats the thing which doesnt work then it's because u tried to install it over the net and in your ~/.m2 folder there is some maven metadata file which tells maven to keep trying to get it over the network

thedavidmeister12:05:15

if i have [com.datomic/datomic-pro "0.9.5344”] in boot

thedavidmeister12:05:28

then where do i find it?

levitanong12:05:37

hmmm actually this problem sounds familiar

onetom12:05:01

so first just rm -rf ~/.m2/repository/com/datomic/datomic-pro/

onetom12:05:20

then bin/maven-install and boot whatever and it will work

levitanong12:05:41

what i do is have a :repositories arg in set-env!

levitanong12:05:08

(conj % ["my-datomic" {
                  :url      ""
                  :username “xxx"
                  :password “xxx"}])

thedavidmeister12:05:13

@onetom: where actually is that bin/maven-install if boot pulled it down?

levitanong12:05:24

That way, you just get the repo from datomic’s servers

onetom12:05:29

@levitanong: which is the more complicated way and u have to inlcude your secret into it and not something u can remember easily

thedavidmeister12:05:40

:repositories  [["clojars"       ""]
                  ["maven-central" ""]
                  ["datomic"       {:url      ""
                                    :username (System/getenv "DATOMIC_REPO_USERNAME")
                                    :password (System/getenv "DATOMIC_REPO_PASSWORD")}]]

onetom12:05:18

@thedavidmeister: if boot has successfully downloaded it then u dont need that bin/maven-install

levitanong12:05:28

Okay, I think i’ll defer to @onetom in this matter. My knowledge about maven is limited.

thedavidmeister12:05:13

ok so basically...

thedavidmeister12:05:30

my end goal is just to have some datomic thingo running so i can save some data in it, locally

onetom12:05:37

i was not following the conversation though. i just saw the error message and it looked familiar.

thedavidmeister12:05:38

not trying to get anything up in the cloud yet

levitanong12:05:12

That’s weird. My :repositories is a function, while yours is a vector of vectors.

thedavidmeister12:05:38

so if i do a repl

thedavidmeister12:05:43

i can (require ‘datomic.api) and then do stuff

onetom12:05:52

it's a bit off-topic on the #C08BDAPRA channel, btw

thedavidmeister12:05:39

yeah that’s fair

levitanong12:05:45

I do suppose this could go to #C053K90BR

thedavidmeister12:05:59

well maybe i don’t need boot?

thedavidmeister12:05:02

i don’t know...

thedavidmeister12:05:37

i was hoping to just have castra talking to datomic

onetom12:05:41

if you are happy with trying things our with an in-memory db first, then u don't need anything else just the free version of the datomic client because it contains the "in-memory transactor"

thedavidmeister12:05:57

yeah but i don’t know how to set up either

micha12:05:00

@onetom: the *validate-only* var is what i use to do serverside validation

thedavidmeister12:05:05

some tutorials say one thing, others say another

onetom12:05:38

@thedavidmeister: do u want to do a screen sharing session? i can help quickly

thedavidmeister12:05:40

so if i have castra setup, will the in-memory db work between ajax calls?

onetom12:05:19

thedavidmeister: yes

thedavidmeister12:05:48

well it’s probably working enough for now then 😛

micha12:05:52

@onetom: when you bind that to true in the client and you call an rpc function the backend rpc fn is called, but the body of it is not evaluated (only the preconditions)

thedavidmeister12:05:05

when do i lose the memory db?

onetom12:05:47

@micha: i saw the code, but i dont understand why would you want to do such a thing

onetom12:05:13

@thedavidmeister: when u stop your jvm

micha12:05:16

i have a state machine that handles interaction with the backend

micha12:05:25

and forms in the client

micha12:05:41

the state machine can be in "validation" mode

thedavidmeister12:05:17

@onetom: oooh ok, so as long as i have serve running with boot, i get the same db, so castra will work. That sounds good enough for experimentation for a bit simple_smile

micha12:05:21

like if you submit the form and the server rejects it becaue of validation fail

micha12:05:14

@onetom: the crucial thing is that when you're validating input you must not evaluate the body of the rpc fn

l1sp3r12:05:33

hi a question around focus, i have a use-case where users are editing a dom of code, i want to move focus around the dom. two ways I can think of to do this, 1) have a toggle of focus on each node, 2) after an update set focus explicitly, is there a ‘best practice’ approach?

onetom12:05:49

so you are using it to reflect validation errors during form fill?

micha12:05:57

because sometimes you just want to validate input that the user is typing, but the user doesn't want side effects to happen

micha12:05:24

like the user isn't submitting the form, so you can't transact on the database

micha12:05:50

but you want to have the server validate what they have in the incomplete form

micha12:05:21

yeah it's mostly used like that, during form fill

thedavidmeister12:05:01

why don’t you save the user input always, but have a way of knowing whether the input is “safe” or not for general usage?

micha12:05:47

we don't want to change the database unless the user intends to submit

micha12:05:11

that would be very confusing for the user if we were accepting input in the backend as they type

thedavidmeister12:05:31

why would the user know what you put in the database?

micha12:05:48

well suppose they're running ad campaigns at adzerk

micha12:05:06

when they start seeing those ads show up on their website they know it got into our database

thedavidmeister12:05:19

oooh, i mean, have an extra thing in the database

micha12:05:20

that could be very bad news if it happens accidentally

thedavidmeister12:05:26

a place to put raw input

thedavidmeister12:05:35

that the user doesn’t see

thedavidmeister12:05:43

until they make it match validation rules

micha12:05:11

currently that place is in the cell in the client

micha12:05:20

in the form state machine thingy

thedavidmeister12:05:06

oh, but you do validation server side?

micha12:05:10

why would i want to save that in the database?

micha12:05:22

yes all serverside validation for now

micha12:05:41

there is a hook for having clientside validation but we don't use it

thedavidmeister12:05:46

i dunno? i’m literally about to try this approach, i’ll let you know how i go 😛

micha12:05:54

because serverside validation is free and no perf impact yet

onetom12:05:24

@micha: and what do u think about the automatic unauthorized response handling in castra?

micha12:05:35

the nice thing about serverside validation is that it's automatic

micha12:05:44

@onetom: what is that?

micha12:05:08

sorry a lot of stuff in the scroll buffer

thedavidmeister12:05:11

well, what if a user was struggling with the validation

thedavidmeister12:05:15

if you had the raw input in the db

onetom12:05:21

@micha: i described it just below my question about the *validate-only*

thedavidmeister12:05:23

your support staff could see the problem straight away

thedavidmeister12:05:25

that’s one idea

thedavidmeister12:05:07

if you rolled a new release that relaxed validation rules for something that was previously invalid, maybe you could retroactively allow things already in the system

onetom12:05:28

@thedavidmeister: thats how @jumblerg is planning to extend hoplon. storing the whole frontend state in datomic so you can replay or join any user session any time

thedavidmeister12:05:08

if people were consistently failing validation, you’d have data to do UX review on

thedavidmeister12:05:42

@onetom: i’ve been using datascript for front end state

thedavidmeister12:05:05

@onetom: it’s OK, but for my use case i’m finding that having a few different dbs and cells in different ns is better than one big one

micha12:05:22

@onetom: i don't understand what you mean with the two requests above?

micha12:05:48

like returning the response for #2 to #1?

micha12:05:02

and the connection to promises?

micha12:05:17

@thedavidmeister: i see whta you mean now with saving in the database

micha12:05:50

that would be pretty sweet, and you could activate that behavior in castra when validate-only is bound

micha12:05:08

if you're using datomic i can see how it would be pretty awesome to have that

micha12:05:27

unfortunately i don't think we can use datomic

micha12:05:44

i mean at adzerk

thedavidmeister12:05:31

i’m playing around with this:

thedavidmeister12:05:36

(defprotocol ISafe
  "Safe values can be extracted from raw user input"
  (raw    [this] "The raw user input")
  (safe   [this] "The safe version of whatever the user input")
  (raw?   [this] "Is there any user input at all?")
  (safe?  [this] "Is the user's input safe?”))

thedavidmeister12:05:17

then an input on a form would have something like

thedavidmeister12:05:20

(h/input
                :type "text"
                :data-raw (j/cell= (item-data/raw? v))
                :data-safe (j/cell= (item-data/safe? v))
                :value (j/cell= (item-data/raw v))

micha12:05:26

i was thinking like middleware perhaps

thedavidmeister12:05:45

sure, i’m just messing around with it client side

micha12:05:02

in your :rpc/pre for example

micha12:05:07

you could have middleware there

micha12:05:11

like for instance:

micha12:05:22

(defrpc foo [{:keys [bar baz]} :as args}]
  {:rpc/pre (validate (record args))}
  ...

micha12:05:43

where record puts the things in the debug database if *validate-only* is bound

thedavidmeister12:05:48

you could see what people are constantly getting wrong

micha12:05:32

that's aweosme when you can check out a copy of the database that is rewound in time to when the validation failed

micha13:05:06

when you don't have datomic it gets less useful i think, but still probably worthwhile to have

thedavidmeister13:05:34

how come you can’t use datomic at adzerk?

thedavidmeister13:05:38

is there a problem with it?

micha13:05:43

it's closed source and the licensing is complicated, which scares people

micha13:05:32

postgres or ms sql server is a less stressful choice for such a core thing for them

thedavidmeister13:05:54

ah, so it’s byo db for your customers?

micha13:05:04

like how does datomic work when you have 150 peers?

micha13:05:21

no it would have to be a core thing for our business

micha13:05:39

i mean we'd need to store mission critical stuff in there

thedavidmeister13:05:42

i thought the whole thing was you could have as many peers as you want?

micha13:05:56

the most you can buy is 8 peers last time i checked

micha13:05:04

then you start negotiating

micha13:05:28

the close source part is the real problem for us i guess

micha13:05:42

assuming the cost for the number of peers we need would be reasonable

micha13:05:15

like what if cognitect goes under or what if there are intellectual property issues with datomic

micha13:05:37

in the contract it says they can pull your license with 10 days notice

micha13:05:56

we'd basically go out of business if that happened probably, if our whole thing was relying on it

thedavidmeister13:05:19

so who is paying for it then?

micha13:05:01

i'd be very interested to talk to them, yeah

micha13:05:18

there must be some huge enterprise customers for it

dm313:05:31

I don't think they'd pull a license that way

thedavidmeister13:05:33

i wonder if it would be OK to just stick entities somewhere

thedavidmeister13:05:41

like, in rethinkdb or something

dm313:05:47

have you ever heard of that happening e.g. for Oracle/other db providers?

micha13:05:13

yeah there have been incidents, i forget the most recent one

micha13:05:32

some nosql database went belly up and disappeared i think

onetom13:05:37

@micha: yes, 2nd response (if succeeds) would be the response of the 1st request. im just talking about retrying the rpc call, which would be "interrupted" by a login screen.

micha13:05:50

@onetom that seems like something you'd want on the frontend, maybe

micha13:05:54

not the backend

micha13:05:12

you could implement retries there, in the state machine

onetom13:05:36

yup, im talking about xhr calls on the frontend

micha13:05:36

having a staet machine that mediates interaction with the backend is pretty key for that

onetom13:05:02

you have mentioned it a few times but not sure what do u mean by that

onetom13:05:36

last time u said u will show an example later but we never got back to it

micha13:05:45

ah yeah i started making a demo

micha13:05:56

then i got sidetracked trying to find better abstractions

micha13:05:16

what i have currently is a somewhat naive implementation that works

micha13:05:27

but doesn't seem as elegant as it should be

micha13:05:45

but the state machine representation problem is pretty deep i think

onetom13:05:45

if u could share it i might be able to think it further

micha13:05:54

yeah i'll do that today

micha13:05:12

i went downt he rabbithole of UML statecharts and such

micha13:05:26

publishing the code will be the best first step i think

alandipert13:05:01

the doomsday scenario is somebody buys datomic just to shut it down

dm313:05:52

yeah, heard about that one

micha13:05:30

haha "innovation"

micha13:05:49

my nodejs application with 10000 alpha release databases

micha13:05:12

my app to put mustaches on phone selfies

micha13:05:21

we must protect innovation

thedavidmeister13:05:43

ah yeah, foundationdb

thedavidmeister13:05:45

i was using that

thedavidmeister13:05:56

luckily, not for much 😉

thedavidmeister13:05:15

is apple going to buy adzerk and take away my hoplon?

micha13:05:58

haha it's open source and you have commit access to the repo

micha13:05:09

so i don't think that's possible

dm313:05:40

it's also a bit simpler to reimplement once you are familiar with the ideas simple_smile

thedavidmeister13:05:20

i am definitely not able to make database software

micha13:05:26

once it's open source you can fork it

thedavidmeister13:05:28

it’s ok, i have other skills

micha13:05:33

the license you have is good forever

micha13:05:59

so if the hoplon repo were shut down you could just make a fork and coninue

thedavidmeister13:05:08

yeah i’d fork it

micha13:05:24

the problem is when you don't have the source

thedavidmeister13:05:26

i’d rather not have to though

dm313:05:27

well, if you consider a scenario where github decided to remove every fork

dm313:05:37

but that's probably fantasy

micha13:05:48

yeah you'd need to use bitbucket then or your own repo

thedavidmeister13:05:49

that’s true, github is buyable by apple too

micha13:05:52

but you could stll do it

dm313:05:59

if you had the source

thedavidmeister13:05:00

lol “apple bought github to shut down all competitors everywhere"

dm313:05:31

imagine tomorrow you find that notice on http://github.com

micha13:05:49

yeah i have local copies of everything

dm313:05:51

that would be a bit worse than pulling an .isArray package from NPM

micha13:05:19

it would be widespread chaos

micha13:05:43

lol it would be like the dark ages

micha13:05:55

everyone computing in the dark in their hovels

micha13:05:21

roasting human flesh on spits and drowning witches

dm313:05:31

If I was running Apple, I'd probably buy bitbucket, gitlab and github and shut down just for laughs simple_smile

micha13:05:40

haha right

micha13:05:47

it's now on iTunes

micha13:05:52

sign up fuckers or die

dm313:05:54

0.99 per repo

micha13:05:19

you would need to have it approved before you can push a commit

micha13:05:32

they might put a nsfw tag on it

thedavidmeister13:05:12

anyone here used rethinkdb before?

thedavidmeister13:05:25

looks like they have a query powered data streaming thing

thedavidmeister13:05:34

wondering how hard it would be to plug into javelin

micha13:05:09

if it's event-driven you can just attach events to a function that does swap!

thedavidmeister14:05:17

yeah i don’t know if that’s exactly how it works

thedavidmeister14:05:24

i’ll just read up and play around simple_smile

thedavidmeister14:05:50

changes
(changes table)
Return an infinite stream of objects representing changes to a table or a document.

thedavidmeister14:05:57

i think that’s where i’d do it

thedavidmeister14:05:13

but actually, that happens server side

thedavidmeister14:05:24

maybe castra is not the right thing here

l1sp3r16:05:43

having issues with cond-tpl, the test isn't firing

l1sp3r16:05:09

I have something like: (cond-tpl (string? some-cell) ...)

l1sp3r16:05:19

is that allowed?

micha17:05:52

@l1sp3r: i thin kyou need (cond-tpl (cell= (string? some-cell)) ...)

micha17:05:20

(string? some-cell) is always false

micha17:05:31

without the (cell= ...) wrapping it

l1sp3r17:05:51

Ah makes sense, thanks!

leontalbot19:05:23

With (env/def KEY "value") "value" will be use as KEY key only if there is no environnement variable set-up, correct?

micha19:05:14

yes, it's a default setting

beatngu1321:05:46

Hey guys! I just started with Hoplon and I really like it! I'm using the default template from the tutorial (`boot -d seancorfield/boot-new new -t hoplon -n address-book`), but somehow there's no output generated when I run boot prod or boot hoplon. What am I missing?

leontalbot23:05:29

@beatngu13: hi! Temp solution: If you want to test hoplon, you can also do lein new hoplon address-book

leontalbot23:05:21

You can then run with boot dev