Introducing Golang Code Example documentation to use this Rulio Engine#65
Introducing Golang Code Example documentation to use this Rulio Engine#65HemantJoshi11 wants to merge 1 commit intoComcast:masterfrom
Conversation
|
@jsccast pls review. |
|
Forgive me as I am only an observer here, not a maintainer, but perhaps the use of the word "client" is not appropriate here? The code base has a reference HTTP API, and my thought in seeing this PR was that you were offering an example client for that API. Perhaps a more appropriate way to present this is as an example engine. |
jsccast
left a comment
There was a problem hiding this comment.
Thanks for the PR.
The biggest requested changes are to reference/use existing code rather than copy/pasting code. See sys.System.SearchFacts and all those other important System methods for examples. Maybe you don't want to use those methods for some reason. If so, what's the rationale?
Thanks again for the PR.
|
|
||
| ### Starting | ||
| To run execute go run main.go | ||
| .../rulio\examples\go-client>go run main.go |
There was a problem hiding this comment.
Those backlashes are confusing (and won't work on non-Windows platforms).
Also that line should probably be marked up as code. Similarly for the code in the line above.
|
|
||
| ``` | ||
| ### Sample output | ||
| ```Shell |
There was a problem hiding this comment.
The text in this block isn't shell input. Maybe just drop the Shell?
| {"id":"ID is: ","result":"498a3b4e-5c44-4942-bab3-9380f8361bff Work is: ""}%!(EXTRA *core.FindRules=&{map[age:30 city:London code:SEC-3423 name:John] complete [0xc0002fe280] [city Lond | ||
| on]}) | ||
| Result is: { | ||
| "event": { |
There was a problem hiding this comment.
This JSON should probably be in Markdown JSON code block:
{"like":"this"}| GenericEnvConfig | ||
| } | ||
|
|
||
| type EngineEnvConfig struct { |
There was a problem hiding this comment.
Seems like we shouldn't repeat this kind of struct here when we have (for example) sys. SystemConfig. Can you refactor to use existing structs?
| } | ||
|
|
||
| type EngineEnvConfig struct { | ||
| // "linear (or indexed) state? |
| "time" | ||
| ) | ||
|
|
||
| type EnginePoc struct { |
There was a problem hiding this comment.
Is there a way to refactor this code to use sys.System? Looks like you are duplicating a lot of code.
| return &EnginePoc{Ctx: ctx, Service: engineService}, nil | ||
| } | ||
|
|
||
| type BashActionInterpreter struct { |
There was a problem hiding this comment.
Probably shouldn't duplicate code like this. Can you just reference/use existing types instead of copy/pasting code?
| "time" | ||
| ) | ||
|
|
||
| type Service struct { |
There was a problem hiding this comment.
How is this Service different from service.Service? A comment there would be helpful.
| package service | ||
|
|
||
| import ( | ||
| "encoding/json" |
There was a problem hiding this comment.
Imports should probably be organized by standard packages, packages in this repo, and third-party packages. You can use blank lines to separate those groups of imports.
| Stopper func(*core.Context, time.Duration) error | ||
| } | ||
|
|
||
| func (s *Service) SearchFact(ctx *core.Context, m map[string]interface{}) error { |
There was a problem hiding this comment.
Why repeat all of this implementation when we have sys.System.SearchFacts? Can you refactor to use existing code?
Golang Code Example documentation to use this Rulio Engine
This code commit contain