mirror of
https://github.com/go-micro/go-micro.git
synced 2025-06-30 22:33:49 +02:00
Further consolidate the libraries
This commit is contained in:
31
service/grpc/examples/greeter/function/main.go
Normal file
31
service/grpc/examples/greeter/function/main.go
Normal file
@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/micro/go-micro"
|
||||
"github.com/micro/go-micro/service/grpc"
|
||||
hello "github.com/micro/go-micro/service/grpc/examples/greeter/server/proto/hello"
|
||||
)
|
||||
|
||||
type Say struct{}
|
||||
|
||||
func (s *Say) Hello(ctx context.Context, req *hello.Request, rsp *hello.Response) error {
|
||||
rsp.Msg = "Hello " + req.Name
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
fn := grpc.NewFunction(
|
||||
micro.Name("go.micro.fnc.greeter"),
|
||||
)
|
||||
|
||||
fn.Init()
|
||||
|
||||
fn.Handle(new(Say))
|
||||
|
||||
if err := fn.Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user