example

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(conn *grpc.ClientConn, logger log.Logger, options ...kitGRPC.ClientOption) *grpcClient

func NewPBFromReply

func NewPBFromReply(msg *Reply) *pb.Reply

transformer *Reply to *pb.Reply

func NewPBFromRequest

func NewPBFromRequest(msg *Request) *pb.Request

transformer *Request to *pb.Request

Types

type ClientOption

type ClientOption func(*grpcClient)

func ClientAfter

func ClientAfter(after ...ClientResponseFunc) ClientOption

func ClientBefore

func ClientBefore(before ...ClientRequestFunc) ClientOption

type ClientRequestFunc

type ClientRequestFunc func(context.Context, *metadata.MD) context.Context

type ClientResponseFunc

type ClientResponseFunc func(context.Context, metadata.MD, metadata.MD) context.Context

type Endpoints

type Endpoints struct {
	HalfDuplexEndpoint endpoint.Endpoint // half duplex
	FullDuplexEndpoint endpoint.Endpoint //  full duplex
}

func MakeEndpoints

func MakeEndpoints(svc Service, mwares []endpoint.Middleware) Endpoints

type GRPCServer

type GRPCServer struct {
	HalfDuplexGRPCHandler kitGRPC.Handler // TODO : half duplex
	FullDuplexGRPCHandler kitGRPC.Handler // TODO : full duplex
	// contains filtered or unexported fields
}

func NewGRPCServer

func NewGRPCServer(endpoints Endpoints, logger log.Logger, options ...kitGRPC.ServerOption) (*GRPCServer, error)

func (*GRPCServer) FullDuplex

func (s *GRPCServer) FullDuplex(stream pb.Streams_FullDuplexServer) error

protobuf implementation : full duplex for FullDuplex

func (*GRPCServer) HalfDuplex

func (s *GRPCServer) HalfDuplex(req *pb.Request, stream pb.Streams_HalfDuplexServer) error

protobuf implementation : half duplex for HalfDuplex

type Reply

type Reply struct {
	Msg string
}

func NewReplyFromPB

func NewReplyFromPB(msg *pb.Reply) *Reply

transformer *pb.Reply to *Reply

type Repository

type Repository interface {
	HalfDuplex(ctx context.Context, msg string) (string, error)
	FullDuplex(ctx context.Context, msg string) (string, error)
}

*

type MysqlConfig struct {
	Host              string `env:"DB_READ_HOST" envDefault:"local-example"`
	Port              string `env:"DB_READ_PORT" envDefault:"3306"`
	ConnectionTimeout int    `env:"DB_READ_CONNECTION_TIMEOUT" envDefault:"5"`
	MaxConnLifetime   int    `env:"DB_READ_MAX_CONN_LIFETIME" envDefault:"0"`
	MaxIdleConns      int    `env:"DB_READ_MAX_IDLE_CONNS" envDefault:"2"`
	MaxOpenConns      int    `env:"DB_READ_MAX_OPEN_CONNS" envDefault:"0"`
	ReadTimeout       int    `env:"DB_READ_READ_TIMEOUT" envDefault:"360"`
	Username          string `env:"DB_READ_USERNAME" envDefault:"root"`
	Password          string `env:"DB_READ_PASSWORD" envDefault:"foobar"`
	DatabaseName      string `env:"DB_READ_DATABASE" envDefault:"example"`
}

* *

*

func NewRepository

func NewRepository(logger log.Logger, db interface{}) Repository

type Request

type Request struct {
	Msg string
}

func NewRequestFromPB

func NewRequestFromPB(msg *pb.Request) *Request

transformer *pb.Request to *Request

type RequestAndStreamHalfDuplex

type RequestAndStreamHalfDuplex struct {
	Request *pb.Request
	Stream  pb.Streams_HalfDuplexServer
}

request and stream for half duplex

type Service

type Service interface {
	BroadcastHalfDuplex() chan Reply
	HalfDuplex(req *pb.Request, stream pb.Streams_HalfDuplexServer) error // half duplex (client request, server streams)
	BroadcastFullDuplex() chan Reply
	FullDuplex(stream pb.Streams_FullDuplexServer) error // full duplex (both client and server streams)
	Log() log.Logger
}

func NewService

func NewService(log log.Logger, repo Repository) Service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL