Skip to content

Commit

Permalink
decouple sc client from go chassis (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
tianxiaoliang authored Dec 10, 2020
1 parent f54bd13 commit e6740a2
Show file tree
Hide file tree
Showing 31 changed files with 539 additions and 7,902 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
pull_request:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.29
args: --skip-dirs=examples --out-format=colored-line-number --skip-files=.*_test.go$
21 changes: 21 additions & 0 deletions .github/workflows/static_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Merge check
on: [push, pull_request]
jobs:
build:
name: Merge check
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Build
run: go build -v .
- name: UT
run: |
bash scripts/ci/start_latest_sc.sh
go get github.com/stretchr/testify
bash scripts/ci/unit_test.sh
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

41 changes: 35 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
### Service-Center Client for Go-Chassis
[![Build Status](https://travis-ci.org/go-chassis/go-sc-client.svg?branch=master)](https://travis-ci.org/go-chassis/go-sc-client)
This is a service-center client which helps the microservice to interact with Service-Center
for service-registration, discovery, instance registration and dependency management.
# 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 all the [api's](https://rawcdn.githack.com/go-chassis/service-center/master/docs/api-docs.html) of Service-Center.
This client implements all the [api's](https://rawcdn.githack.com/go-chassis/service-center/master/docs/api-docs.html) of Service Center.


# Usage

**NOTICE**: this client is migrate to github.com/go-chassis/go-chassis/pkg/scclient
```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)
```
Loading

0 comments on commit e6740a2

Please sign in to comment.