Fork me on GitHub
#clojure
<
2015-06-24
>
bmay00:06:52

i can't seem to "get" a value from a lazyseq

bmay00:06:04

keep getting not found or null

ppold00:06:28

@narkisr: I don’t know about secure but you can also check http://nanomsg.org/index.html

Busy escaping the comfort zone00:06:11

it looks nice but I don't see any mentioning of a security protocol

arrdem00:06:39

bmay: yeah get IIRC only works on indexable collections which are maps or vectors. you have to use nth/first/rest on seqs.

bmay00:06:54

yeah, just found first

ppold00:06:25

@narkisr: yes you are right, I just checked how MQTT and SQS handle security and I don’t think nanomsg has those features in their protocol

Busy escaping the comfort zone00:06:22

Yeah, my issue with mqtt is that id rather not maintain a server (peer to peer is much better in my use case)

Busy escaping the comfort zone00:06:54

Yeap, ill probably use SQS hopfully it will work behind most firewalls

bmay03:06:42

what is the purpose of a "-main" function?

bmay04:06:42

"You'll notice that we defined a "-main" function. This is a convention that we can take advantage of by adding a :main option to our project.clj."

bmay04:06:52

i don't get it

gary04:06:34

@bmay it's the entry point of the application

gary04:06:57

when you call lein run that is what it looks for

niwinz05:06:31

Seems that fits your requirements. Is p2p and with security in mind. The only drawback is that I'm not pretty sure if is actively developed.

lucasbradstreet07:06:29

I’ve created a protocol in clojure, and used gen-interface to generate the corresponding methods. I’m now attempting to use this interface from Java but I’m hitting errors because there is no implementation of the method for that protocol on the java side. Do I need to use extend-protocol?

lucasbradstreet07:06:13

My main problem is that I have code that can be called on something that implements the protocol, or something that implements the corresponding java interface

niwinz07:06:33

A protocol is represented as java interface only if you put a implementation inline with deftype or defrecord

lucasbradstreet07:06:38

Yep, I’ve done that. I’m actually trying to make it so users of Onyx's java bindings can implement the same protocol.

niwinz07:06:38

in other sircumstances (using extend-*) the dispatch is done dinamically. So the type doesn't magically implements a interface of the protocol.

lucasbradstreet07:06:11

They’re implementing the interface created by the protocol using gen-interface

lucasbradstreet07:06:36

I may be using gen-interface when I shouldn’t be

lucasbradstreet07:06:40

"defprotocol will automatically generate a corresponding interface, with the same name as the protocol, i.e. given a protocol: my.ns/Protocol, an interface: my.ns.Protocol” I thought this meant it will generate a Java interface too

niwinz07:06:57

I'm not pretty sure that gen-interface is a way. As far as I know the protocols interface is generated dinamically when it is needed.

niwinz07:06:10

maybe i'm wrong

lucasbradstreet07:06:13

Yeah, that’s seeming more and more likely at least

niwinz07:06:59

reading that docstring, you should will be able use the protocol interface directly, without any gen-interface...

lucasbradstreet07:06:31

I think I know what’s going on

lucasbradstreet07:06:56

Hrm, nope, still unable to import them.

lucasbradstreet07:06:06

I’ll have more of a play

bozhidar09:06:20

I’ve been pushing for a while for source-tracking evaluation support in nREPL

bozhidar09:06:57

that’s an important change that would be beneficial to pretty much all the Clojure editors (except Cursive I guess)

bozhidar09:06:29

If you want to help out, please voice your support for the patch attached here http://dev.clojure.org/jira/browse/NREPL-59

bozhidar09:06:20

basically, without this code evaluated via nREPL’s eval will not have proper location metadata (meaning commands like find-definition, etc won’t work)

Busy escaping the comfort zone09:06:50

@niwinz: Iris looks very nice but sadly its not opensource for commercial projects

Petrus Theron10:06:01

Given a vector of entities, each with an :id keyword, what's a nice way to transform the vector into a hash-map, indexed by :id?

Petrus Theron10:06:05

e.g. [{:id 1 :name "Entity 1"} {:id 2 "Entity 2"} {:id 3 "Entity 3"}] =>

{1 {:id 1 :name "Entity 1"}
2 {:id 2 "Entity 2"}
3 {:id 3 "Entity 3"}}
Sort of like group-by, but expecting only one entity per :id value.

mikethompson10:06:33

(def v  [{:id 1 :other 4} {:id 2 :other 5}])

(zipmap (map :id v) v)
;;=>  {2 {:id 2, :other 5}, 1 {:id 1, :other 4}}

andrewhr13:06:43

@lucasbradstreet: the problems is not related with lack of AOT compilation?

lucasbradstreet13:06:58

@andrewhr I think it may have been due to underscores (which were -s in clj) in the namespace. I was able to reproduce it with gen interface when I did the same there. I didn't get a chance to test the theory because I've settled on creating interfaces using Java naming conventions and then implementing the protocol. That way I can use the idiomatic naming for each.

andrewhr13:06:11

nice! Also less magic for Java eyes

bmay13:06:25

@gary: but whats the difference between "main" and "-main"?

lucasbradstreet13:06:17

Ha. I learned this one today! Putting - in front of a function makes it a static Java method on the namespace, rather than a regular Clojure fn

lucasbradstreet13:06:41

(I spent a lot of time trying to call Clojure stuff from Java today ha)

lucasbradstreet13:06:01

I should really lookup whether that is actually true. But it's the gist.

bmay13:06:18

yeah, im trying to find documentation of that, but cant find anything

bmay13:06:22

yeah was just to post that

lucasbradstreet13:06:37

In my case it was a gen-class method. It did seem to be interpreted differently though.

lucasbradstreet13:06:55

Stuart Sierra thinks differently so I am v v likely wrong

lucasbradstreet14:06:30

Ahhhh. Because it's the default prefix

lucasbradstreet14:06:40

For gen-class methods.

lucasbradstreet14:06:29

Explains a lot of the trouble I was having today. I thought the default prefix would be ""

lucasbradstreet14:06:55

So it does have special significance to gen-class, but not the /compiler/

bmay14:06:59

cool cool

lucasbradstreet14:06:15

Yeah, I also read that one and saw the mention of prefixes but it didn't trigger that - was the default

Lambda/Sierra17:06:44

@lucasbradstreet: The "-" prefix only has significance for methods which are declared in the gen-class.

Lambda/Sierra17:06:04

That is, just naming a function "-foo" does not create a method in the generated Java class.

noisesmith17:06:59

@mikethompson: @petrus: another alternative (that doesn't walk the collection twice) (into {} (map (juxt :id identity) v))

noisesmith17:06:42

I mean walking the collection twice usually isn't a huge issue, but it can be nice to have a version that doesn't do so

noisesmith17:06:55

I have a tiny beef with zipmap, where most usages I see in the wild would be better with a transducing and/or transient using function like my one liner above (taking to functions and a seq, returning a hash-map)

ghadi18:06:53

select-keys with transducers: (fn [m keys] (into {} (map #(find m %)) keys))

Lambda/Sierra18:06:47

@ghadi Don't you need a map in there?

ghadi18:06:33

stuartsierra: thx

ghadi18:06:54

thankfully slack is not persistent data structures

malabarba21:06:36

@narkisr thanks for the help yesterday

hlship21:06:08

I was really pleased at Clojure/West this year to see that other people have hit some of the same server-configuration issues we have at Aviso. I've written up a good sized posting about io.aviso/config: https://medium.com/@hlship/microservices-configuration-and-clojure-4f6807ef9bea

rauh21:06:49

@malabarba: Did you use delay and force for this?

malabarba21:06:33

@rauh no, that would have been the smart way

malabarba21:06:01

I used a lazy sequences to hold the values

malabarba21:06:54

But that's just a detail,

malabarba21:06:38

I'll switch it to delays tomorrow

rauh21:06:45

Oh I see now.

Busy escaping the comfort zone21:06:27

BTW another option for lazy values is using promises

Busy escaping the comfort zone21:06:51

still it looks well implemented nice work

Busy escaping the comfort zone21:06:12

Oh just saw you guys already mentioned delays

arohner22:06:56

using bidi, is there a way to handle “overlapping” routes, with priority? I have [“foo/“ :id] as a route, but then I want to special case “foo/42” to be a different route. I know I could use regex, but is there a better way?

jeluard22:06:26

@hlship: Great work! Definitively something I would use.

jeluard22:06:10

@hlship: How do you deal with envs other than dev or prod? Do you build different binaries?

hlship22:06:45

@jeluard: Currently, we build a single Uberjar that has multiple entry points in it. That may change in the future, but it's been very good for deployment. We have a few options for dealing with multiple environments; it is possible to specify on the command line both key-path/value overrides and paths to additional configuration files, on the file system.

hlship22:06:41

So, in practice, we have a "fan-default-configuration.yaml" on the classpath, and a /srv/config.yaml (for each service) that provides the overrides and configuration specific that that service.

hlship22:06:16

Our AMI has a single Docker image in it, but we use CloudFormation templates to build a docker.env file specific for each server type, which combines with the /srv/config.yaml (also specific to the server type) inside the Docker image.

hlship22:06:36

Things will probably get a bit simpler with our upcoming shift to Amazon ECS.

jeluard22:06:56

@hlship: Looks like you've nailed it. A great companion to the various component libraries.

hlship22:06:27

Yes, we use it with Stu's component. I think we're a bit unusual in that the configuration map is exposed as a dependency to the other components, rather than being provided to each component at component creation time; this works much better with our approach of not even knowing what the components will be ... it just makes it easier to manipulate and then merge the system sub-graphs.

hlship22:06:31

I don't think I made that clear; our startup is all done through a central function called "bootstrap" that merges a minimal system graph with a set of components provided as arguments. It can then read the configuration and provided that as a dependency in the final system graph.

hlship22:06:38

Requiring the configuration to be provided at creation time, rather than as a dependency, means we can't have that logic centralized ... and that makes it even more tricky since we don't know exactly what components (and what configuration schemas) will be in play at the time we would have to create the components.

hlship22:06:19

Intead, each component has meta-data about its schema, so once we have (most of) the system graph, we can extract and merge those schemas, assemble the configuration, and build the system from the final map, which includes the configuration as a component.

jeluard23:06:43

Indeed that's a bit unusual! Nice to have that level of flexibility.

ej23:06:42

How are people handling deployment to AWS Elastic Beanstalk with Datomic and Docker containers?

ej23:06:27

Better to have circleci send a webhook and have the API reload the docker containers with shell commands etc?

ej23:06:39

docker compose + linked containers?

ej23:06:45

but then again, you could also use lein beanstalk/boot beanstalk but have one Docker container with Datomic + Boot/leiningen in the same container?!

ej23:06:50

what’s the easiest?

arohner23:06:15

@ej I build a docker container on circle, then docker push, then use beanstalk’s set version API

arohner23:06:01

deployment: prod: branch: master commands: - lein prod-build - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD -e $DOCKER_EMAIL - lein do docker build, docker push, beandock deploy production