github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/service/store/server/server.go (about) 1 package store 2 3 import ( 4 pb "github.com/tickoalcantara12/micro/v3/proto/store" 5 "github.com/tickoalcantara12/micro/v3/service" 6 log "github.com/tickoalcantara12/micro/v3/service/logger" 7 "github.com/tickoalcantara12/micro/v3/service/store/handler" 8 "github.com/urfave/cli/v2" 9 ) 10 11 var ( 12 // name of the store service 13 name = "store" 14 // address is the store address 15 address = ":8002" 16 ) 17 18 // Run micro store 19 func Run(ctx *cli.Context) error { 20 if len(ctx.String("server_name")) > 0 { 21 name = ctx.String("server_name") 22 } 23 if len(ctx.String("address")) > 0 { 24 address = ctx.String("address") 25 } 26 27 // Initialise service 28 service := service.New( 29 service.Name(name), 30 service.Address(address), 31 ) 32 33 // the store handler 34 pb.RegisterStoreHandler(service.Server(), &handler.Store{ 35 Stores: make(map[string]bool), 36 }) 37 38 // the blob store handler 39 pb.RegisterBlobStoreHandler(service.Server(), new(handler.BlobStore)) 40 41 // start the service 42 if err := service.Run(); err != nil { 43 log.Fatal(err) 44 } 45 return nil 46 }