Documentation ¶
Index ¶
- Constants
- func BuildTarget(segment, serviceName string) string
- type BuilderAction
- type DirectResolver
- type ElsaResolver
- type ElsaResolverBuilder
- type ElsaServer
- type InitAction
- type ManagedSentinel
- type RegistryStub
- func (r *RegistryStub) Cancel(ctx context.Context, serviceName, ip string, port int32) (bool, error)
- func (r *RegistryStub) Fetch(cxt context.Context, serviceName string) ([]*pb.ServiceInstance, error)
- func (r *RegistryStub) GetSegment() string
- func (r *RegistryStub) Register(ctx context.Context, serviceName, ip string, port int32) (bool, error)
- func (r *RegistryStub) Renew(ctx context.Context, serviceName, ip string, port int32) (bool, error)
- type Sentinel
- type ServerOption
- type ServerOptions
Constants ¶
const ( DefaultServerName = "elsa" DefaultSegment = "elsa" DefaultServerPort = 8001 DefaultRegistryEndpoint = "127.0.0.1:8005" )
const ( DirectScheme = "direct" ElsaScheme = "elsa" )
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 ¶
Types ¶
type BuilderAction ¶
type DirectResolver ¶
type DirectResolver struct {
// contains filtered or unexported fields
}
func NewDirectResolverWithEndpoints ¶
func NewDirectResolverWithEndpoints(endpoints []string) *DirectResolver
func (*DirectResolver) Build ¶
func (r *DirectResolver) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error)
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) 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 ¶
func NewElsaResolver ¶
func NewElsaResolver(serviceName string, cli resolver.ClientConn, registryStub *RegistryStub) *ElsaResolver
new a elsa 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 ¶
func NewElsaResolverBuilder ¶
func NewElsaResolverBuilder(stub *RegistryStub) *ElsaResolverBuilder
new a elsa resolver
func (*ElsaResolverBuilder) Build ¶
func (r *ElsaResolverBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error)
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{}
type InitAction ¶
type ManagedSentinel ¶
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
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
}