client

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultServerName       = "elsa"
	DefaultSegment          = "elsa"
	DefaultServerPort       = 8001
	DefaultRegistryEndpoint = "127.0.0.1:8005"
)
View Source
const (
	DirectScheme = "direct"
	ElsaScheme   = "elsa"
)
View Source
const (
	RetryTimeDuration = time.Second * 3        // retry time duration
	RenewTimeDuration = time.Second * 30       // renew time duration
	TimeoutDuration   = time.Millisecond * 500 // renew time duration
)

Variables

This section is empty.

Functions

func BuildTarget

func BuildTarget(segment, serviceName string) string

Types

type BuilderAction

type BuilderAction func(server *grpc.Server) (serverNames []string)

type DirectResolver

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

func NewDirectResolverWithEndpoints

func NewDirectResolverWithEndpoints(endpoints []string) *DirectResolver

func (*DirectResolver) Build

Build creates a new resolver for the given target.

gRPC dial calls Build synchronously, and fails if the returned error is not nil.

func (*DirectResolver) Close

func (r *DirectResolver) Close()

Close closes the resolver.

func (*DirectResolver) ResolveNow

func (r *DirectResolver) ResolveNow(opts resolver.ResolveNowOptions)

ResolveNow will be called by gRPC to try to resolve the target name again. It's just a hint, resolver can ignore this if it's not necessary.

It could be called multiple times concurrently.

func (*DirectResolver) Scheme

func (r *DirectResolver) Scheme() string

Scheme returns the scheme supported by this resolver. Scheme is defined at https://github.com/grpc/grpc/blob/master/doc/naming.md.

type ElsaResolver

type ElsaResolver struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewElsaResolver

func NewElsaResolver(serviceName string, cli resolver.ClientConn, registryStub *RegistryStub) *ElsaResolver

new a elsa resolver

func (*ElsaResolver) Close

func (r *ElsaResolver) Close()

Close closes the resolver.

func (*ElsaResolver) ResolveNow

func (r *ElsaResolver) ResolveNow(opts resolver.ResolveNowOptions)

ResolveNow will be called by gRPC to try to resolve the target name again. It's just a hint, resolver can ignore this if it's not necessary.

It could be called multiple times concurrently.

type ElsaResolverBuilder

type ElsaResolverBuilder struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewElsaResolverBuilder

func NewElsaResolverBuilder(stub *RegistryStub) *ElsaResolverBuilder

new a elsa resolver

func (*ElsaResolverBuilder) Build

Build creates a new resolver for the given target.

gRPC dial calls Build synchronously, and fails if the returned error is not nil.

func (*ElsaResolverBuilder) Scheme

func (r *ElsaResolverBuilder) Scheme() string

Scheme returns the scheme supported by this resolver. Scheme is defined at https://github.com/grpc/grpc/blob/master/doc/naming.md.

type ElsaServer

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

func NewElsaServer

func NewElsaServer(options ...ServerOption) (*ElsaServer, error)

new elsa server

func (*ElsaServer) BuildStub

func (s *ElsaServer) BuildStub(serviceName string, callback func(cc *grpc.ClientConn) interface{}) interface{}

func (*ElsaServer) Init

func (s *ElsaServer) Init(action InitAction)

init elsa server

func (*ElsaServer) Start

func (s *ElsaServer) Start() error

start the elsa server

type InitAction

type InitAction func(server *grpc.Server) (serverNames []string)

type ManagedSentinel

type ManagedSentinel struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewManagedSentinel

func NewManagedSentinel(serverPort int32, registryStub *RegistryStub) *ManagedSentinel

func (*ManagedSentinel) Close

func (m *ManagedSentinel) Close()

func (*ManagedSentinel) PushService

func (m *ManagedSentinel) PushService(serviceName string)

type RegistryStub

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

func NewRegistryStub

func NewRegistryStub(segment string, endpoints []string) (*RegistryStub, error)

new a registry stub

func (*RegistryStub) Cancel

func (r *RegistryStub) Cancel(ctx context.Context, serviceName, ip string, port int32) (bool, error)

cancel a service instance

func (*RegistryStub) Fetch

func (r *RegistryStub) Fetch(cxt context.Context, serviceName string) ([]*pb.ServiceInstance, error)

fetch service instance list

func (*RegistryStub) GetSegment

func (r *RegistryStub) GetSegment() string

func (*RegistryStub) Register

func (r *RegistryStub) Register(ctx context.Context, serviceName, ip string, port int32) (bool, error)

register a service instance

func (*RegistryStub) Renew

func (r *RegistryStub) Renew(ctx context.Context, serviceName, ip string, port int32) (bool, error)

renew a service instance

type Sentinel

type Sentinel struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type ServerOption

type ServerOption func(options *ServerOptions)

func WithName

func WithName(name string) ServerOption

func WithRegistryStub

func WithRegistryStub(stub *RegistryStub) ServerOption

func WithServerPort

func WithServerPort(serverPort int32) ServerOption

type ServerOptions

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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