Categorygithub.com/go-chassis/sc-client
modulepackage
0.7.0
Repository: https://github.com/go-chassis/sc-client.git
Documentation: pkg.go.dev

# README

Service Center client for go

This is a service center client which helps the microservice to interact with Service Center for service-registration, discovery, instance registration etc.

This client implements API of Service Center.

Usage

registryClient, err := sc.NewClient(
	sc.Options{
		Addrs: []string{"127.0.0.1:30100"},
	})

declare and register micro service

var ms = new(discovery.MicroService)
var m = make(map[string]string)

m["abc"] = "abc"
m["def"] = "def"

ms.AppId = MSList[0].AppId
ms.ServiceName = MSList[0].ServiceName
ms.Version = MSList[0].Version
ms.Environment = MSList[0].Environment
ms.Properties = m
sid, err := registryClient.RegisterService(ms)

declare and register instance

	microServiceInstance := &discovery.MicroServiceInstance{
		Endpoints: []string{"rest://127.0.0.1:3000"},
		HostName:  hostname,
		Status:    sc.MSInstanceUP,
	}
	id, err := registryClient.RegisterMicroServiceInstance(microServiceInstance)

# Functions

NewClient create a the service center client.
NewCommonException creates a generic exception.
NewIOException create and IO exception.
NewJSONException creates a JSON exception.
NewPool Get registry pool instance.
RoundRobin Gives the next object in sequence.
WithGlobal query resources include other aggregated SC.
WithoutRevision ignore current revision number.

# Constants

Define constants for the client.
Define constants for the client.
CheckByHeartbeat is a constant of type string.
Define constants for the client.
DefaultLeaseRenewalInterval is a constant of type int which declares default lease renewal time.
Define constants for the client.
Define constants for the client.
Define constants for the client.
EnvCheckSCIInterval sc instance health check interval in second.
Define constants for the client.
EventCreate is a constant of type string.
EventDelete is a constant of type string.
EventError is a constant of type string.
EventUpdate is a constant of type string.
Define constants for the client.
Define constants for the client.
Define constants for the client.
Define constants for the client.
Define constants for the client.
Define constants for the client.
Define constants for the client.
MicorserviceUp is a constant of type string.
MicroserviceDown is a constant of type string.
Define constants for the client.
MSIinstanceDown is a constant of type string.
MSInstanceUP is a constant of type string.
Define constants for the client.
Define constants for the client.
Define constants for the client.
Define constants for the client.
Define constants for the client.

# Variables

ErrEmptyCriteria means you gave an empty list of criteria.
ErrMicroServiceExists means service is registered.
ErrMicroServiceNotExists means service is not exists.
No description provided by the author
ErrNoneAvailable create a new error with Message No available.
ErrNotModified means instance is not changed.
Define variables for the client.
Define variables for the client.
Define variables for the client.

# Structs

AddressPool registry address pool.
CallOptions is options when you call a API.
Client communicate to Service-Center.
MicroServiceInstanceChangedEvent is a struct to store the Changed event information.
MicroServiceProvideResponse is a struct with provider information.
Options is the list of dynamic parameter's which can be passed to the Client while creating a new client.
RegistryException structure contains message and error information for the exception caused by service-center.
URLBuilder is the string builder to build request url.

# Type aliases

CallOption is receiver for options and chang the attribute of it.
Next gives the next object in the list.
URLParameter maintains the list of parameters to be added in URL.