vert-x / mod-lang-clojure

Vert.x 2.x is deprecated - use instead
http://vertx.io
Other
74 stars 15 forks source link

Keywords sent over eventbus and sockjs bridge lose namespace #124

Closed Jared314 closed 10 years ago

Jared314 commented 10 years ago

My server process responds to an event on the Vert.x eventbus, sent using js client library and sockjs bridge, with a hash-map whose keys are namespaced keywords.

{ :workorder/company "Company Name 1" }

When I access the results, in the reply function on the js client, the keywords arrive with the namespace set to null.

cljs.core.Keyword {ns: null, name: "company", fqn: "company", _hash: null, …}

The namespace is also lost on keywords sent from the js client.

tobias commented 10 years ago

We lose the namespace for symbols when we encode to json for the eventbus. If you need a higher-fidelity format, I recommend encoding the data as edn or transit to a string before sending it, then decoding it on the other side. I don't think it would be difficult to write a few wrapper functions to handle that for you. Will that solve your use-case?

Jared314 commented 10 years ago

Encoding it manually will work as a short-term workaround.

I can understand stripping symbol namespaces, but a keyword namespace, because of its use in preventing key collisions, feels like something that should be preserved.

tobias commented 10 years ago

I took a closer look at this, and I think you're right - we should write namespaced keywords out to json as "workorder/company". The keyword function in older versions of cljs wouldn't restore the namespace, but it looks like recent cljs versions do (or at least the latest (0.0-2322) does). I'll try to get this implemented in the next couple of days and get a release out.

tobias commented 10 years ago

Implemented in https://github.com/vert-x/mod-lang-clojure/commit/96eaa9884402981438d0fc4af7031865600413b5. I've released 1.0.4-SNAPSHOT - can you give that a try and see if it works for you? You'll need to update conf/langs.properties in your vert.x install, but won't need to recompile your clojurescript.

Jared314 commented 10 years ago

That fixed it for me. Thank you.

tobias commented 10 years ago

Great, thanks for the feedback. I'll try to get a release out early next week.

tobias commented 10 years ago

This was released as part of 1.0.4.