Skip to content

tornado-ssy/sc-client

 
 

Repository files navigation

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)

About

Go client of ServiceComb Service Center

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.4%
  • Shell 0.6%