Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/go-chassis/sc-client

Go client of ServiceComb Service Center
https://github.com/go-chassis/sc-client

microservice servicecomb

Last synced: 1 day ago
JSON representation

Go client of ServiceComb Service Center

Awesome Lists containing this project

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](https://github.com/apache/servicecomb-service-center/blob/master/docs/openapi/v4.yaml) of Service Center.

# Usage

```go
registryClient, err := sc.NewClient(
sc.Options{
Addrs: []string{"127.0.0.1:30100"},
})
```
declare and register micro service
```go
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
```go
microServiceInstance := &discovery.MicroServiceInstance{
Endpoints: []string{"rest://127.0.0.1:3000"},
HostName: hostname,
Status: sc.MSInstanceUP,
}
id, err := registryClient.RegisterMicroServiceInstance(microServiceInstance)
```