Report meta info to opensergo
refer to opensergo-dashboard and run opensergo-dashboard
refer to opensergo-specification and set environment variables
export OPENSERGO_BOOTSTRAP_CONFIG={\"endpoint\":\"127.0.0.1:9090\"}
package main
import (
...
"github.com/cloudwego/kitex/server"
"github.com/kitex-contrib/opensergo/metainfo"
...
)
func main() {
...
r, err := metainfo.NewDefaultMetaReporter()
if err != nil {
panic(err)
}
svr := hello.NewServer(
new(HelloImpl),
)
server.RegisterStartHook(func() {
if err = r.ReportMetaInfo(svr.GetServiceInfo()); err != nil {
klog.Error(err)
}
})
...
}
go run example/server/main.go
See example
sentinel adapter for kitex
bf := func(ctx context.Context, req, resp interface{}, blockErr error) error {
return errors.New(FakeErrorMsg)
}
srv := hello.NewServer(new(HelloImpl),
server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: "hello"}),
server.WithMiddleware(SentinelServerMiddleware(
WithBlockFallback(bf),
)))
bf := func(ctx context.Context, req, resp interface{}, blockErr error) error {
return errors.New(FakeErrorMsg)
}
c, err := hello.NewClient("hello",
client.WithMiddleware(SentinelClientMiddleware(
WithBlockFallback(bf))))
if err != nil {
t.Fatal(err)
}