Any Golang libs for defining business logic in a serializable format?

polaris · 2017-02-13 15:00:10 · 668 次点击    
这是一个分享于 2017-02-13 15:00:10 的资源,其中的信息可能已经有所发展或是发生改变。

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:

I eventually found what I was after here: https://github.com/elgs/jsonql

printf_hello_world:

I'm not familiar with jsonlogic, but have you checked out the encoding/gob package? Also, net/rpc?

Admiral_Aubergine:

What Im trying to do is find a format to define the logic, not send or receive it. Im already using net/rpc.

printf_hello_world:

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

jns111:

Have you thought about go plugins? https://tip.golang.org/pkg/plugin/

PsyWolf:

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.

neoasterisk:

https://goa.design/

mcandre:

encoding/json

qu33ksilver:

"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 ?

PsyWolf:

You could use something like https://github.com/robertkrimen/otto to call JsonLogic from your go code.

jns111:

Want to achieve distributed map reduce like functionality? How about Lua/JS?


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

668 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传