Coder Social home page Coder Social logo

warlock's Introduction

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.ServerAdds = &[]string{"127.0.0.1:50051"}
    
        //  or
        cfg := warlock.NewConfig(warlock.OptionNoOverFlow, warlock.WithServerAdd(&[]string{"127.0.0.1:50051"}))
	



        pool, err := warlock.NewWarlock(cfg, grpc.WithInsecure())
	conn, close, err := pool.Acquire()
	defer close()

	
    /*
        Connection pool is not necessary for grpc
	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.

warlock's People

Contributors

dependabot[bot] avatar ruiboma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

warlock's Issues

typo in time.Duration usage

// Acquire  Fishing a usable link from the pool
func (w *Pool) Acquire() (*grpc.ClientConn, CloseFunc, error) {
	ctx, cancel := context.WithTimeout(context.Background(), w.Config.AcquireTimeout*time.Second)

w.Config.AcquireTimeout is in seconds, there is no need to use w.Config.AcquireTimeout * time.Second?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.