forked from micro/micro
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.go
executable file
·46 lines (39 loc) · 985 Bytes
/
server.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
package store
import (
pb "github.com/2637309949/micro/v3/proto/store"
"github.com/2637309949/micro/v3/service"
log "github.com/2637309949/micro/v3/service/logger"
"github.com/2637309949/micro/v3/service/store/handler"
"github.com/urfave/cli/v2"
)
var (
// name of the store service
name = "store"
// address is the store address
address = ":8002"
)
// Run micro store
func Run(ctx *cli.Context) error {
if len(ctx.String("server_name")) > 0 {
name = ctx.String("server_name")
}
if len(ctx.String("address")) > 0 {
address = ctx.String("address")
}
// Initialise service
service := service.New(
service.Name(name),
service.Address(address),
)
// the store handler
pb.RegisterStoreHandler(service.Server(), &handler.Store{
Stores: make(map[string]bool),
})
// the blob store handler
pb.RegisterBlobStoreHandler(service.Server(), new(handler.BlobStore))
// start the service
if err := service.Run(); err != nil {
log.Fatal(err)
}
return nil
}