1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-01-17 17:44:30 +02:00
Asim Aslam d94936f6c9
v3 (#2104)
* v3

* revert plugins

* fixup some issues
2021-01-20 13:54:31 +00:00

45 lines
829 B
Go

// Package main
package main
import (
"context"
"time"
hello "github.com/micro/go-micro/examples/greeter/srv/proto/hello"
"github.com/asim/go-micro/v3"
"github.com/asim/go-micro/v3/util/log"
"google.golang.org/grpc"
)
type Say struct{}
func (s *Say) Hello(ctx context.Context, req *hello.Request, rsp *hello.Response) error {
log.Log("Received Say.Hello request")
rsp.Msg = "Hello " + req.Name
return nil
}
func main() {
go func() {
for {
grpc.DialContext(context.TODO(), "127.0.0.1:9091")
time.Sleep(time.Second)
}
}()
service := micro.NewService(
micro.Name("go.micro.srv.greeter"),
)
// optionally setup command line usage
service.Init()
// Register Handlers
hello.RegisterSayHandler(service.Server(), new(Say))
// Run server
if err := service.Run(); err != nil {
log.Fatal(err)
}
}