/warlock

grpcpool grpc client Connection pool

Primary LanguageGoApache License 2.0Apache-2.0

warlock -- grpc client Connection pool

Build Status LICENSE GoDoc Open Source Helpers Go Report Card

This is the golang grpc client connection pool tool
Complete link state detection mechanism Every link obtained is efficient.

Project Maturity

Basic api will not have more changes. They will be discussed on Github issues along with any bugs or enhancements

Goals

Provide a few interfaces, as efficient, stable and flexible as possible.

Doc

warlock
clientFactory

HOW TO USE

go get github.com/ruiboma/warlock
package main

import (
	"github.com/ruiboma/warlock"
	"google.golang.org/grpc"
	pb "google.golang.org/grpc/examples/helloworld/helloworld"
)

func main() {

	cfg := warlock.NewConfig()
	cfg.MaxCap = 100
	cfg.OverflowCap = true      
	cfg.ServerAdds = &[]string{"127.0.0.1:50051"}


	pool, err := warlock.NewWarlock(cfg, grpc.WithInsecure())
	defer pool.ClearPool()


	conn, close, err := pool.Acquire()
	defer close()


	


	// start use
	c := pb.NewYourClient(conn)S
	r, err := c.YourRPCFunc(ctx,balabala..)
    ...



    /*
	used, free := pool.Getstat() // Can view usage and free quantities
	cfg.OverflowCap = true  This configuration may cause the existing link to exceed the total number set.
	If it overflows for a long time you need to consider increasing the value of cap.
	defer pool.ClearPool()  // Close all existing links with the pool before exiting the program
	defer close()  // It is recommended to use this, or <pool.Close(conn)> func
    */

License

see LICENSE for more details.