You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
599 B
31 lines
599 B
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/go-kratos/kratos/examples/stream/hello"
|
|
"github.com/go-kratos/kratos/examples/stream/service"
|
|
"github.com/go-kratos/kratos/v2"
|
|
"github.com/go-kratos/kratos/middleware/recovery/v2"
|
|
"github.com/go-kratos/kratos/v2/transport/grpc"
|
|
)
|
|
|
|
func main() {
|
|
grpcSrv := grpc.NewServer(
|
|
grpc.Address(":9001"),
|
|
grpc.Middleware(
|
|
recovery.Recovery(),
|
|
),
|
|
)
|
|
hello.RegisterHelloServer(grpcSrv, service.NewHelloService())
|
|
|
|
app := kratos.New(
|
|
kratos.Name("hello"),
|
|
kratos.Server(
|
|
grpcSrv,
|
|
),
|
|
)
|
|
if err := app.Run(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|