overflow_server_app/grpc/pool_handlers.go
2017-09-05 15:37:33 +09:00

31 lines
617 B
Go

package grpc
import (
"context"
"google.golang.org/grpc"
"git.loafle.net/commons_go/config"
cgp "git.loafle.net/commons_go/grpc_pool"
oas "git.loafle.net/overflow/overflow_api_server/golang"
"go.uber.org/zap"
)
type poolHandlers struct {
cgp.PoolHandlers
ctx context.Context
logger *zap.Logger
cfg config.Configurator
}
func (h *poolHandlers) OnCreate() (*grpc.ClientConn, interface{}, error) {
var err error
conn, err := grpc.Dial(config.GetString("grpc.addr"), grpc.WithInsecure())
if nil != err {
return nil, nil, err
}
c := oas.NewOverflowApiServerClient(conn)
return conn, c, nil
}