Skip to content

kitex-contrib/loadbalance-tagging

Repository files navigation

Tagging Loadbalance

Divide the cluster into different subsets based on tags on the client, suitable for stateful services or multi-tenant services

How to use?

Client

import (
	...
	"github.com/cloudwego/kitex/client"
	tagging "github.com/kitex-contrib/loadbalance-tagging"
	...
)

func main() {
	...
	// create a LoadBalancer with loadbalance 
	client, err := client.NewClient("echo", client.WithLoadBalancer(tagging.New(tag, tagFunc, nextLoadBalancer)))
	if err != nil {
		log.Fatal(err)
	}
	...
}

Multi-tag selector can be implemented by combining tag selectors in sequence

import (
	...
	"github.com/cloudwego/kitex/client"
	tagging "github.com/kitex-contrib/loadbalance-tagging"
	...
)

func main() {
	... 
	// create a LoadBalancer with multi-tag selectors 
	client, err := client.NewClient("echo", 
		client.WithLoadBalancer(tagging.New(tag1, tag1Func, tagging.New(tag2, tag2Func, nextLoadBalancer))))
	if err != nil {
		log.Fatal(err)
	}
	...
}

Maintainer

maintained by: jizhuozhi ([email protected])

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published