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

polaris · · 467 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi,</p> <p>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!)?</p> <hr/>**评论:**<br/><br/>Admiral_Aubergine: <pre><p>I eventually found what I was after here: <a href="https://github.com/elgs/jsonql" rel="nofollow">https://github.com/elgs/jsonql</a></p></pre>printf_hello_world: <pre><p>I&#39;m not familiar with jsonlogic, but have you checked out the encoding/gob package? Also, net/rpc?</p></pre>Admiral_Aubergine: <pre><p>What Im trying to do is find a format to define the logic, not send or receive it. Im already using net/rpc.</p></pre>printf_hello_world: <pre><p>Huh, interesting. I&#39;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?</p> <p>Toy example: <a href="https://play.golang.org/p/VJ9-F_x08K" rel="nofollow">https://play.golang.org/p/VJ9-F_x08K</a></p></pre>jns111: <pre><p>Have you thought about go plugins? <a href="https://tip.golang.org/pkg/plugin/" rel="nofollow">https://tip.golang.org/pkg/plugin/</a></p></pre>PsyWolf: <pre><p>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 <a href="http://www.youtube.com/watch?v=tY4UKkgb5IY&amp;t=19m53s" rel="nofollow">http://www.youtube.com/watch?v=tY4UKkgb5IY&amp;t=19m53s</a> for a great demo on go plugins. </p> <p>Edit: on second glance, since JsonLogic like don&#39;t use eval, you probably could implement a JsonLogic lib in go without plugins, but it&#39;d be hard without duck typing.</p></pre>neoasterisk: <pre><p><a href="https://goa.design/" rel="nofollow">https://goa.design/</a></p></pre>mcandre: <pre><p>encoding/json</p></pre>qu33ksilver: <pre><p>&#34;business logic&#34; in serializable format ? </p> <p>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 ?</p></pre>PsyWolf: <pre><p>You could use something like <a href="https://github.com/robertkrimen/otto" rel="nofollow">https://github.com/robertkrimen/otto</a> to call JsonLogic from your go code.</p></pre>jns111: <pre><p>Want to achieve distributed map reduce like functionality? How about Lua/JS?</p></pre>

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

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