ergo

command
v0.0.0-...-ee38212 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 10 Imported by: 0

README

Ergo Framework

This is the boilerplate code generator to create a service with Ergo Framework. To install it, use the following command:

go install ergo.services/tools/ergo@latest

Please follow this pattern, keeping the order of declaration according to the supervision tree of your project:

ParentActor:Actor{param1:value1,param2:value2...}

Options

  • -init Node name

    params:

    • ssl:yes enables SSL for the node
    • module defines module name

    example: ergo -init "myService{ssl:yes,module:github.com/user/example}"

  • -path defines location for the generated code

  • -with-actor add actor (based on gen.Server)

  • -with-app add application (based on gen.Application)

  • -with-sup add supervisor (based on gen.Supervisor)

    params:

    • type supervisor strategy type. available values:

      • ofo (default) one for one - If a child process terminates, only that process is restarted
      • rfo rest for one - If a child process terminates, the rest of the child processes are terminated, then the terminated child process and the rest of the child processes are restarted
      • ofa one for all - If a child process terminates, all other child processes are terminated, and then all child processes, including the terminated one, are restarted
      • sofo simple one for one - is a simplified ofo supervisor, where all child processes are dynamically added instances of the same process
    • restart restart strategy. available values:

      • trans (default) transient - child process is restarted only if it terminates abnormally
      • perm permanent - child process is always restarted
      • temp temporary - child process is never restarted

    example: ergo -init myService -with-sup{type:rfo,restart:perm}"

  • -with-cloud enables Cloud feature for the node

  • -with-msg add message for the networking

    params:

    • strict:yes enable strict mode for unmarshaling message
  • -with-pool add pool of workers (based on gen.Pool)

    params:

    • workers number of starting workers
  • -with-raft add raft (based on gen.Raft)

  • -with-saga add saga (based on gen.Saga)

  • -with-stage add stage (based on gen.Stage)

  • -with-tcp add TCP server (based on gen.TCP)

    params:

    • ssl:yes enables SSL for this TCP server
    • host defines hostname
    • port defines port number
    • handlers number of starting handlers
  • -with-udp add UDP server (based on gen.UDP)

    params:

    • host defines hostname
    • port defines port number
    • handlers number of starting handlers
  • -with-web add Web server (based on gen.Web)

    params:

    • ssl:yes enables SSL for this Web server
    • host defines hostname
    • port defines port number
    • handlers number of starting handlers

See ergo -help for more information

Example:

Supervision tree

mynode
|- myapp
|   |
|    `- mysup
|        |
|         `- myactor
|- myweb
`- myactor2

To generate project for this design use the following command:

ergo -init MyNode -with-app MyApp -with-sup MyApp:MySup -with-actor MySup:MyActor -with-web "MyWeb{port:8000,handlers:3}" -with-actor MyActor2

as a result you will get generated project:

   mynode/
   |-- apps/
   |   `-- myapp/
   |       |-- myactor.go
   |       |-- myapp.go
   |       `-- mysup.go
   |-- cmd/
   |   |-- myactor2.go
   |   |-- mynode.go
   |   |-- myweb.go
   |   `-- myweb_handler.go
   |-- README.md
   |-- go.mod
   `-- go.sum

to try it:

$ cd mynode
$ go run ./cmd/

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL