client

package module
v0.0.0-...-369f58c Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

README

Service-Center Client for Go-Chassis

Build Status This is a service-center client which helps the microservice to interact with Service-Center for service-registration, discovery, instance registration and dependency management.

This client implements all the api's of Service-Center.

Documentation

Index

Constants

View Source
const (
	MicroservicePath    = "/microservices"
	InstancePath        = "/instances"
	SchemaPath          = "/schemas"
	HeartbeatPath       = "/heartbeat"
	ExistencePath       = "/existence"
	WatchPath           = "/watcher"
	StatusPath          = "/status"
	DependencyPath      = "/dependencies"
	PropertiesPath      = "/properties"
	HeaderContentType   = "Content-Type"
	HeaderUserAgent     = "User-Agent"
	DefaultAddr         = "127.0.0.1:30100"
	AppsPath            = "/apps"
	DefaultRetryTimeout = 500 * time.Millisecond
	HeaderRevision      = "X-Resource-Revision"
	EnvProjectID        = "CSE_PROJECT_ID"
)

Define constants for the client

Variables

View Source
var (
	MSAPIPath     = ""
	TenantHeader  = ""
	GovernAPIPATH = ""
)

Define variables for the client

View Source
var (
	//ErrNotModified means instance is not changed
	ErrNotModified = errors.New("instance is not changed since last query")
	//ErrMicroServiceExists means service is registered
	ErrMicroServiceExists = errors.New("micro-service already exists")
)
View Source
var ErrNoneAvailable = errors.New("No available")

ErrNoneAvailable create a new error with Message No available

Functions

This section is empty.

Types

type Next

type Next func() (string, error)

Next gives the next object in the list

func RoundRobin

func RoundRobin(eps []string) Next

RoundRobin Gives the next object in sequence

type Options

type Options struct {
	Addrs        []string
	EnableSSL    bool
	ConfigTenant string
	Timeout      time.Duration
	TLSConfig    *tls.Config
	// Other options can be stored in a context
	Context    context.Context
	Compressed bool
	Verbose    bool
	Version    string
}

Options is the list of dynamic parameter's which can be passed to the RegistryClient while creating a new client

type RegistryClient

type RegistryClient struct {
	Config *RegistryConfig
	// contains filtered or unexported fields
}

RegistryClient is a structure for the client to communicate to Service-Center

func (*RegistryClient) AddDependencies

func (c *RegistryClient) AddDependencies(request *model.MircroServiceDependencyRequest) error

AddDependencies : 注册微服务的依赖关系

func (*RegistryClient) AddSchemas

func (c *RegistryClient) AddSchemas(microServiceID, schemaName, schemaInfo string) error

AddSchemas adds a schema contents to the services registered in service-center

func (*RegistryClient) Close

func (c *RegistryClient) Close() error

Close closes the connection with Service-Center

func (*RegistryClient) FindMicroServiceInstances

func (c *RegistryClient) FindMicroServiceInstances(consumerID, appID, microServiceName,
	versionRule string) ([]*model.MicroServiceInstance, error)

FindMicroServiceInstances find microservice instance using consumerID, appID, name and version rule

func (*RegistryClient) GetAllApplications

func (c *RegistryClient) GetAllApplications() ([]string, error)

GetAllApplications returns the list of all the applications which is registered in governance-center

func (*RegistryClient) GetAllMicroServices

func (c *RegistryClient) GetAllMicroServices() ([]*model.MicroService, error)

GetAllMicroServices gets list of all the microservices registered with Service-Center

func (*RegistryClient) GetAllResources

func (c *RegistryClient) GetAllResources(resource string) ([]*model.ServiceDetail, error)

GetAllResources retruns all the list of services, instances, providers, consumers in the service-center

func (*RegistryClient) GetDefaultHeaders

func (c *RegistryClient) GetDefaultHeaders() http.Header

GetDefaultHeaders gets the default headers for each request to be made to Service-Center

func (*RegistryClient) GetMicroService

func (c *RegistryClient) GetMicroService(microServiceID string) (*model.MicroService, error)

GetMicroService returns the microservices by ID

func (*RegistryClient) GetMicroServiceID

func (c *RegistryClient) GetMicroServiceID(appID, microServiceName, version, env string) (string, error)

GetMicroServiceID gets the microserviceid by appID, serviceName and version

func (*RegistryClient) GetMicroServiceInstances

func (c *RegistryClient) GetMicroServiceInstances(consumerID, providerID string) ([]*model.MicroServiceInstance, error)

GetMicroServiceInstances queries the service-center with provider and consumer ID and returns the microservice-instance

func (*RegistryClient) GetProviders

func (c *RegistryClient) GetProviders(consumer string) (*model.MicroServiceProvideresponse, error)

GetProviders gets a list of provider for a particular consumer

func (*RegistryClient) GetSchema

func (c *RegistryClient) GetSchema(microServiceID, schemaName string) ([]byte, error)

GetSchema gets Schema list for the microservice from service-center

func (*RegistryClient) HTTPDo

func (c *RegistryClient) HTTPDo(method string, rawURL string, headers http.Header, body []byte) (resp *http.Response, err error)

HTTPDo makes the http request to Service-center with proper header, body and method

func (*RegistryClient) Health

func (c *RegistryClient) Health() ([]*model.MicroServiceInstance, error)

Health returns the list of all the endpoints of SC with their status

func (*RegistryClient) Heartbeat

func (c *RegistryClient) Heartbeat(microServiceID, microServiceInstanceID string) (bool, error)

Heartbeat sends the heartbeat to service-senter for particular service-instance

func (*RegistryClient) Initialize

func (c *RegistryClient) Initialize(opt Options) (err error)

Initialize initializes the Registry Client

func (*RegistryClient) RegisterMicroServiceInstance

func (c *RegistryClient) RegisterMicroServiceInstance(microServiceInstance *model.MicroServiceInstance) (string, error)

RegisterMicroServiceInstance registers the microservice instance to Servive-Center

func (*RegistryClient) RegisterService

func (c *RegistryClient) RegisterService(microService *model.MicroService) (string, error)

RegisterService registers the micro-services to Service-Center

func (*RegistryClient) SyncEndpoints

func (c *RegistryClient) SyncEndpoints() error

SyncEndpoints gets the endpoints of service-center in the cluster

func (*RegistryClient) UnregisterMicroService

func (c *RegistryClient) UnregisterMicroService(microServiceID string) (bool, error)

UnregisterMicroService un-registers the microservice from the service-center

func (*RegistryClient) UnregisterMicroServiceInstance

func (c *RegistryClient) UnregisterMicroServiceInstance(microServiceID, microServiceInstanceID string) (bool, error)

UnregisterMicroServiceInstance un-registers the microservice instance from the service-center

func (*RegistryClient) UpdateMicroServiceInstanceProperties

func (c *RegistryClient) UpdateMicroServiceInstanceProperties(microServiceID, microServiceInstanceID string, microServiceInstance *model.MicroServiceInstance) (bool, error)

UpdateMicroServiceInstanceProperties updates the microserviceinstance prooperties in the service-center

func (*RegistryClient) UpdateMicroServiceInstanceStatus

func (c *RegistryClient) UpdateMicroServiceInstanceStatus(microServiceID, microServiceInstanceID, status string) (bool, error)

UpdateMicroServiceInstanceStatus updates the microservicve instance status in service-center

func (*RegistryClient) UpdateMicroServiceProperties

func (c *RegistryClient) UpdateMicroServiceProperties(microServiceID string, microService *model.MicroService) (bool, error)

UpdateMicroServiceProperties updates the microservice properties in the servive-center

func (*RegistryClient) WatchMicroService

func (c *RegistryClient) WatchMicroService(microServiceID string, callback func(*model.MicroServiceInstanceChangedEvent)) error

WatchMicroService creates a web socket connection to service-center to keep a watch on the providers for a micro-service

type RegistryConfig

type RegistryConfig struct {
	Addresses []string
	SSL       bool
	Tenant    string
}

RegistryConfig is a structure to store registry configurations like address of cc, ssl configurations and tenant name

type URLParameter

type URLParameter map[string]string

URLParameter maintains the list of parameters to be added in URL

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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