overflow_server_app/external/grpc/pool.go

62 lines
1.3 KiB
Go
Raw Normal View History

2017-11-23 08:06:44 +00:00
package grpc
import (
"git.loafle.net/commons_go/logging"
ooas "git.loafle.net/overflow/overflow_api_server/golang"
"git.loafle.net/overflow/overflow_server_app/config"
2018-03-26 14:47:55 +00:00
"google.golang.org/grpc"
2017-11-23 08:06:44 +00:00
)
2018-03-26 14:47:55 +00:00
var grpcClient ooas.OverflowApiServerClient
2017-11-23 08:06:44 +00:00
func ExternalInit() {
2018-03-26 14:47:55 +00:00
conn, err := grpc.Dial(config.Config.GRPC.Addr, grpc.WithInsecure())
if nil != err {
logging.Logger().Panic(err)
2017-11-23 08:06:44 +00:00
}
2018-03-26 14:47:55 +00:00
grpcClient = ooas.NewOverflowApiServerClient(conn)
2017-11-23 08:06:44 +00:00
}
func ExternalDestroy() {
}
2018-03-26 14:47:55 +00:00
// var grpcPool cgp.Pool
// func ExternalInit() {
// ph := &grpcPoolHandlers{}
// ph.MaxCapacity = config.Config.GRPC.Pool.MaxCapacity
// ph.MaxIdle = config.Config.GRPC.Pool.MaxIdle
// ph.IdleTimeout = config.Config.GRPC.Pool.IdleTimeout
// ph.Wait = config.Config.GRPC.Pool.Wait
// grpcPool = cgp.New(ph)
// if err := grpcPool.Start(); nil != err {
// logging.Logger().Panicf("App: %v", err)
// return
// }
// }
// func ExternalDestroy() {
// if nil != grpcPool {
// grpcPool.Stop()
// }
// }
// type grpcPoolHandlers struct {
// cgp.PoolHandlers
// }
// func (h *grpcPoolHandlers) Dial() (*grpc.ClientConn, interface{}, error) {
// var err error
// conn, err := grpc.Dial(config.Config.GRPC.Addr, grpc.WithInsecure())
// if nil != err {
// return nil, nil, err
// }
// c := ooas.NewOverflowApiServerClient(conn)
// return conn, c, nil
// }