Hi,
I want to transfer logic between systems via a restful API or RPC using something like jsonlogic.com. Has anyone seen a golang library that does something like this? even in XML (urgh!)?
评论:
Admiral_Aubergine:
printf_hello_world:I eventually found what I was after here: https://github.com/elgs/jsonql
Admiral_Aubergine:I'm not familiar with jsonlogic, but have you checked out the encoding/gob package? Also, net/rpc?
printf_hello_world:What Im trying to do is find a format to define the logic, not send or receive it. Im already using net/rpc.
jns111:Huh, interesting. I'm not aware of anything that does this in a way like jsonlogic (went and looked it up now), but maybe you could achieve the same sort of thing with reflect?
Toy example: https://play.golang.org/p/VJ9-F_x08K
PsyWolf:Have you thought about go plugins? https://tip.golang.org/pkg/plugin/
neoasterisk:You could definitely use this new language feature to generate go code from the JsonLogic format, write it to disk, and load/execute it on the fly. Check out http://www.youtube.com/watch?v=tY4UKkgb5IY&t=19m53s for a great demo on go plugins.
Edit: on second glance, since JsonLogic like don't use eval, you probably could implement a JsonLogic lib in go without plugins, but it'd be hard without duck typing.
mcandre:
qu33ksilver:encoding/json
PsyWolf:"business logic" in serializable format ?
Not exactly sure what you mean. If you want to transfer structured data via rpc/REST, you can use protobuf for that. I guess calling an rpc function can be termed as business logic. Does that answer your question ?
jns111:You could use something like https://github.com/robertkrimen/otto to call JsonLogic from your go code.
Want to achieve distributed map reduce like functionality? How about Lua/JS?
