31 lines
617 B
Go
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
|
|
|
|
}
|