This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-06-24
Channels
- # admin-announcements (5)
- # beginners (19)
- # boot (48)
- # cider (36)
- # clojure (116)
- # clojure-berlin (2)
- # clojure-italy (2)
- # clojure-japan (40)
- # clojure-russia (11)
- # clojure-sg (2)
- # clojure-spain (11)
- # clojurescript (53)
- # docs (2)
- # editors (14)
- # euroclojure (57)
- # events (2)
- # instaparse (11)
- # ldnclj (14)
- # onyx (2)
- # reading-clojure (4)
- # reagent (28)
@narkisr: I don’t know about secure but you can also check http://nanomsg.org/index.html
it looks nice but I don't see any mentioning of a security protocol
bmay: yeah get IIRC only works on indexable collections which are maps or vectors. you have to use nth/first/rest on seqs.
@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
Yeah, my issue with mqtt is that id rather not maintain a server (peer to peer is much better in my use case)
Yeap, ill probably use SQS hopfully it will work behind most firewalls
"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."
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.
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?
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
A protocol is represented as java interface only if you put a implementation inline with deftype or defrecord
Yep, I’ve done that. I’m actually trying to make it so users of Onyx's java bindings can implement the same protocol.
in other sircumstances (using extend-*) the dispatch is done dinamically. So the type doesn't magically implements a interface of the protocol.
They’re implementing the interface created by the protocol using gen-interface
I may be using gen-interface when I shouldn’t be
"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
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.
Yeah, that’s seeming more and more likely at least
reading that docstring, you should will be able use the protocol interface directly, without any gen-interface...
I think I know what’s going on
Hrm, nope, still unable to import them.
I’ll have more of a play
this doesn’t make it look so hard, but it’s not working at all https://books.google.com.sg/books?id=4aWSAwAAQBAJ&pg=PA391&lpg=PA391&dq=import+protocol+clojure&source=bl&ots=bAOXSVe_IJ&sig=UH0HpfEz-UDitwhs0i94XBFs4aU&hl=en&sa=X&ei=DV-KVf6vKsKxuAT2g4GgAQ&ved=0CBsQ6AEwADgK#v=onepage&q=import%20protocol%20clojure&f=false
that’s an important change that would be beneficial to pretty much all the Clojure editors (except Cursive I guess)
If you want to help out, please voice your support for the patch attached here http://dev.clojure.org/jira/browse/NREPL-59
basically, without this code evaluated via nREPL’s eval
will not have proper location metadata (meaning commands like find-definition
, etc won’t work)
@niwinz: Iris looks very nice but sadly its not opensource for commercial projects
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?
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.(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}}
sweeeet
@lucasbradstreet: the problems is not related with lack of AOT compilation?
@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.
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
(I spent a lot of time trying to call Clojure stuff from Java today ha)
I should really lookup whether that is actually true. But it's the gist.
In my case it was a gen-class method. It did seem to be interpreted differently though.
Stuart Sierra thinks differently so I am v v likely wrong
Ahhhh. Because it's the default prefix
For gen-class methods.
See http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/gen-class
Explains a lot of the trouble I was having today. I thought the default prefix would be ""
So it does have special significance to gen-class, but not the /compiler/
also talks about it here: http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html
Yeah, I also read that one and saw the mention of prefixes but it didn't trigger that - was the default
@lucasbradstreet: The "-" prefix only has significance for methods which are declared in the gen-class
.
That is, just naming a function "-foo" does not create a method in the generated Java class.
@mikethompson: @petrus: another alternative (that doesn't walk the collection twice) (into {} (map (juxt :id identity) v))
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
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)
@ghadi Don't you need a map
in there?
Here's the result https://github.com/Malabarba/lazy-map-clojure
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
@malabarba: Did you use delay
and force
for this?
BTW another option for lazy values is using promises
still it looks well implemented nice work
Oh just saw you guys already mentioned delays
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?
@hlship: How do you deal with envs other than dev or prod? Do you build different binaries?
@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.
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.
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.
@hlship: Looks like you've nailed it. A great companion to the various component libraries.
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.
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.
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.
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.
How are people handling deployment to AWS Elastic Beanstalk with Datomic and Docker containers?
Better to have circleci send a webhook and have the API reload the docker containers with shell commands etc?
but then again, you could also use lein beanstalk/boot beanstalk but have one Docker container with Datomic + Boot/leiningen in the same container?!