-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (45 loc) · 1.44 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"fmt"
"github.com/abaeve/price-cmd/command"
"github.com/abaeve/pricing-service/proto"
"github.com/abaeve/sde-service/proto"
proto "github.com/chremoas/chremoas/proto"
"github.com/chremoas/services-common/args"
"github.com/chremoas/services-common/config"
"github.com/micro/go-micro"
"github.com/micro/go-micro/client"
)
var Version = "1.0.0"
var service micro.Service
var name = "price"
var cmdArgs *args.Args
func main() {
cmdArgs = args.NewArg("price")
//Makes the command's arguments available
//TODO: Maybe this get's moved to the command/handler.go file?
for an, ac := range command.Commands {
cmdArgs.Add(an, ac)
}
service = config.NewService(Version, "bot.command.cmd", name, initialize)
if err := service.Run(); err != nil {
fmt.Println(err)
}
}
// This function is a callback from the config.NewService function. Read those docs
func initialize(config *config.Configuration) error {
proto.RegisterCommandHandler(service.Server(),
command.NewCommand(name, cmdArgs, &clientFactory{c: service.Client(), conf: config}),
)
return nil
}
type clientFactory struct {
c client.Client
conf *config.Configuration
}
func (cf *clientFactory) PricingService() pricing.PricesService {
return pricing.PricesServiceClient(cf.conf.LookupService("srv", "pricing"), cf.c)
}
func (cf *clientFactory) TypeService() sde.TypeQueryService {
return sde.TypeQueryServiceClient(cf.conf.LookupService("srv", "sde"), cf.c)
}