zk

package
v0.0.0-...-ee9fa08 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithInstanceUnmarshaler

func WithInstanceUnmarshaler(u InstanceUnmarshaler) discoveryClientOption

WithInstanceUnmarshaler returns a option specifying a customized InstanceUnmarshaler.

Types

type ConnConfig

type ConnConfig = zk.ConnConfig

type DiscoveryClient

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

DiscoveryClient is a client for service discovery based on zookeeper.

func NewDiscoveryClient

func NewDiscoveryClient(connCfg *ConnConfig, options ...discoveryClientOption) (*DiscoveryClient, error)

NewDiscoveryClient creates a discovery client with given parameters.

func NewDiscoveryClientWithConn

func NewDiscoveryClientWithConn(conn zk.Conn, basePath string, options ...discoveryClientOption) (*DiscoveryClient, error)

NewDiscoveryClientWithConn creates a discovery client with given zk conn and other parameters.

func (*DiscoveryClient) Get

func (c *DiscoveryClient) Get(name string) (*model.Service, error)

Get retrieves a service by name.

func (*DiscoveryClient) List

func (c *DiscoveryClient) List() ([]string, error)

List lists all registered service names.

func (*DiscoveryClient) Run

func (c *DiscoveryClient) Run(ctx context.Context)

Run starts the client until the context is canceled or deadline exceed.

type InstanceUnmarshaler

type InstanceUnmarshaler interface {
	Unmarshal(data []byte) (*model.ServiceInstance, error)
}

InstanceUnmarshaler unmarshals raw byte array which is stored in the underlying registry into a service instance. JSONInstanceUnmarshaler is the default implementation, could customize according to demands.

type JSONInstanceUnmarshaler

type JSONInstanceUnmarshaler struct{}

JSONInstanceUnmarshaler implements the InstanceUnmarshaler interface.

func (*JSONInstanceUnmarshaler) Unmarshal

func (u *JSONInstanceUnmarshaler) Unmarshal(data []byte) (*model.ServiceInstance, error)

Unmarshal unmarshals raw data into a service instance.

Jump to

Keyboard shortcuts

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