pentateu on v0.3.2
pentateu on v0.3.1
pentateu on 0.3.1
pentateu on develop
Merge pull request #91 from mol… Merge commit 'ea742a76c707b0da9… fix payload for map keys with "… and 1 more (compare)
pentateu on payload_key_with_dots
fix payload for map keys with "… (compare)
pentateu on master
chore updated readme chore fixed go.mod chore trying to fix drone build and 7 more (compare)
slaterx on go_modules
slaterx on develop
Bump github.com/tidwall/gjson f… Switching to docker for reenabl… Added kafka service to drone and 5 more (compare)
slaterx on go_modules
Update .drone.yml (compare)
slaterx on go_modules
Update .drone.yml (compare)
slaterx on go_modules
Update .drone.yml (compare)
slaterx on go_modules
Adding wait for kafka command (compare)
package main
import (
"fmt"
"github.com/moleculer-go/gateway"
"github.com/moleculer-go/moleculer"
"github.com/moleculer-go/moleculer/broker"
"github.com/moleculer-go/moleculer/cli"
"github.com/spf13/cobra"
)
type JS struct {
A int json:"awfnieanifnei"
B int json:"wwdfwf"
}
type IMathService interface {
Name() string
Add(params moleculer.Payload) JS
Sub(a int, b int) int
Inc(a int)
}
type MathService struct {
}
func (s *MathService) Name() string {
return "math"
}
func (s MathService) Add(ctx moleculer.Context, params moleculer.Payload) JS {
ctx.Meta.http.resp.
av := params.Get("a").Int()
bv := params.Get("b").Int()
return JS{A: av, B: bv}
}
func (s MathService) Sub(a int, b int) int {
return a - b
}
// ⭐ You can also have an action that receive no parameters ⭐
func (s *MathService) Inc(a int) {
//do magic!
fmt.Println("action passed! ", a)
}
func main() {
mathSvc := &MathService{}
gatewaySvc := &gateway.HttpService{
Settings: map[string]interface{}{"port": "9015"},
}
cli.Start(
&moleculer.Config{LogLevel: "info"},
func(broker *broker.ServiceBroker, cmd *cobra.Command) {
broker.Publish(gatewaySvc, mathSvc)
broker.Start()
})
}