servicekit-go

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2018 License: MIT

README

servicekit for golang

Go Report Card Travis CI Status License MIT

servicekit is a simple, minimum viable service management library for golang.

Quick Start

  • get library

    go get github.com/servicekit/servicekit-go              (>=go1.8)
    
  • coordinator service

     co, err := coordinator.NewConsul("127.0.0.1:8500", "http", "", log)
     if err != nil {
         panic(err)
     }
    
     // Get Services
     services, meta, error:= co.GetServices(context.Background(), "service name", "tag string")
     ...
    
     // Register service
     err := co.Register(context.Background(), spec.Service{ID: "nginx1", Service: "nginx"})
     ...
    
     // Deregister service
     err := co.Deregister(context.Background(), "service_id")
     ...
    
    
  • grpc load balance

    grpc load balance was implemented by https://github.com/grpc/grpc/blob/master/doc/load-balancing.md

     co, err := coordinator.NewConsul("127.0.0.1:8500", "http", "", log)
     if err != nil {
         panic(err)
     }
    
     b, err := balancer.NewConsulBalancer(co, "account_service", "", log)
     if err != nil {
         panic(err)
     }
    
     r := b.GetResolver(context.Background())
    
     conn, err := grpc.Dial(
         "",
         grpc.WithBalancer(grpc.RoundRobin(r)))
     ...
    
    
  • grpc invoke fault tolerant

       i := invoker.NewFailoverInvoker(10, time.Second, invoker.NewFibDelay(time.Second))
       err := i.Invoke(context.Background(), conn, "/Account/Auth", authRequest, authResponse)
       ...
    

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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