zk

package
v2.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseProviders

func CloseProviders()

CloseProviders you must call CloseProviders when program is shutting down, otherwise goroutine will leak

func NewGrpc

func NewGrpc(data ...map[string]interface{})

func NewGrpcClientConn

func NewGrpcClientConn(conf ServiceConfig, lb string, dialOptions ...grpc.DialOption) *grpc.ClientConn

func NewRRGrpcClientConn

func NewRRGrpcClientConn(conf ServiceConfig, dialOptions ...grpc.DialOption) *grpc.ClientConn

NewRRGrpcClientConn is not thread-safe

func NewRest

func NewRest(data ...map[string]interface{})

func NewSWRRGrpcClientConn

func NewSWRRGrpcClientConn(conf ServiceConfig, dialOptions ...grpc.DialOption) *grpc.ClientConn

NewSWRRGrpcClientConn is not thread-safe

func ShutdownGrpc

func ShutdownGrpc()

func ShutdownRest

func ShutdownRest()

Types

type RRServiceProvider

type RRServiceProvider struct {
	// contains filtered or unexported fields
}

RRServiceProvider is a simple round-robin load balance implementation for IServiceProvider

func NewRRServiceProvider

func NewRRServiceProvider(conf ServiceConfig) *RRServiceProvider

NewRRServiceProvider creates new RRServiceProvider instance. If you don't need it, You should call Close to release resource. You can also call CloseProviders to close all at one shot NewRRServiceProvider is not thread-safe

func (*RRServiceProvider) Close

func (r *RRServiceProvider) Close()

func (*RRServiceProvider) SelectServer

func (n *RRServiceProvider) SelectServer() string

SelectServer return service address from environment variable

type SWRRServiceProvider

type SWRRServiceProvider struct {
	*RRServiceProvider
}

SWRRServiceProvider is a smooth weighted round-robin service provider

func NewSWRRServiceProvider

func NewSWRRServiceProvider(conf ServiceConfig) *SWRRServiceProvider

NewSWRRServiceProvider creates new SWRRServiceProvider instance

func (*SWRRServiceProvider) SelectServer

func (n *SWRRServiceProvider) SelectServer() string

SelectServer selects a node which is supplying service specified by name property from cluster

type ServiceConfig

type ServiceConfig struct {
	Name    string
	Group   string
	Version string
}

type Watcher

type Watcher interface {
	Endpoints() []string
	Event() <-chan struct{}
	IsClosed() bool
	Close()
}

A Watcher represents how a serverset.Watch is used so it can be stubbed out for tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL