Skip to content

kitex-contrib/opensergo

Repository files navigation

opensergo (This is a community driven project)

metainfo

Report meta info to opensergo

How to use?

1. Run opensergo-dashboard

refer to opensergo-dashboard and run opensergo-dashboard

2. Set environment variables

refer to opensergo-specification and set environment variables

export OPENSERGO_BOOTSTRAP_CONFIG={\"endpoint\":\"127.0.0.1:9090\"}

3. Run example code

example code
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)
		}
	})
	...
}
command
go run example/server/main.go

Screenshot

More info

See example

sentinel adapter

sentinel adapter for kitex

How to use?

Server

	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),
		)))

Client

	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)
	}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages