Version: v0.0.2 Latest Latest

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




This section is empty.


This section is empty.


func NewClient

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

func NewPBFromFeature

func NewPBFromFeature(msg *Feature) *pb.Feature

transformer *Feature to *pb.Feature

func NewPBFromPoint

func NewPBFromPoint(msg *Point) *pb.Point

transformer *Point to *pb.Point

func NewPBFromRectangle

func NewPBFromRectangle(msg *Rectangle) *pb.Rectangle

transformer *Rectangle to *pb.Rectangle

func NewPBFromRouteNote

func NewPBFromRouteNote(msg *RouteNote) *pb.RouteNote

transformer *RouteNote to *pb.RouteNote

func NewPBFromRouteSummary

func NewPBFromRouteSummary(msg *RouteSummary) *pb.RouteSummary

transformer *RouteSummary to *pb.RouteSummary


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 {
	GetFeatureEndpoint        endpoint.Endpoint
	HalfDuplexEndpoint        endpoint.Endpoint // half duplex
	ReverseHalfDuplexEndpoint endpoint.Endpoint // reverse half duplex
	FullDuplexEndpoint        endpoint.Endpoint //  full duplex

func MakeEndpoints

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

type Feature

type Feature struct {
	Name     string
	Location *Point

func NewFeatureFromPB

func NewFeatureFromPB(msg *pb.Feature) *Feature

transformer *pb.Feature to *Feature

type GRPCServer

type GRPCServer struct {
	GetFeatureGRPCHandler        kitGRPC.Handler
	HalfDuplexGRPCHandler        kitGRPC.Handler // TODO : half duplex
	ReverseHalfDuplexGRPCHandler kitGRPC.Handler // TODO : reverse 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.RouteGuide_FullDuplexServer) error

protobuf implementation : full duplex for FullDuplex

func (*GRPCServer) GetFeature

func (s *GRPCServer) GetFeature(ctx context.Context, req *pb.Point) (*pb.Feature, error)

protobuf implementation : no streaming for GetFeature

func (*GRPCServer) HalfDuplex

func (s *GRPCServer) HalfDuplex(req *pb.Rectangle, stream pb.RouteGuide_HalfDuplexServer) error

protobuf implementation : half duplex for HalfDuplex

func (*GRPCServer) ReverseHalfDuplex

func (s *GRPCServer) ReverseHalfDuplex(stream pb.RouteGuide_ReverseHalfDuplexServer) error

protobuf implementation : reverse half duplex for ReverseHalfDuplex

type Point

type Point struct {
	Latitude  int32
	Longitude int32

func NewPointFromPB

func NewPointFromPB(msg *pb.Point) *Point

transformer *pb.Point to *Point

type Rectangle

type Rectangle struct {
	Lo *Point
	Hi *Point

func NewRectangleFromPB

func NewRectangleFromPB(msg *pb.Rectangle) *Rectangle

transformer *pb.Rectangle to *Rectangle

type Repository

type Repository interface {
	GetFeature(ctx context.Context, latitude int32, longitude int32) (string, *Point, error)
	HalfDuplex(ctx context.Context, lo *Point, hi *Point) (string, *Point, error)
	ReverseHalfDuplex(ctx context.Context, latitude int32, longitude int32) (int32, int32, int32, int32, error)
	FullDuplex(ctx context.Context, location *Point, message string) (*Point, string, error)

* type MysqlConfig struct {

Host              string `env:"DB_READ_HOST" envDefault:"local-route_guide"`
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:"route_guide"`

} * *


func NewRepository

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

type RequestAndStreamHalfDuplex

type RequestAndStreamHalfDuplex struct {
	Request *pb.Rectangle
	Stream  pb.RouteGuide_HalfDuplexServer

request and stream for half duplex

type RouteNote

type RouteNote struct {
	Location *Point
	Message  string

func NewRouteNoteFromPB

func NewRouteNoteFromPB(msg *pb.RouteNote) *RouteNote

transformer *pb.RouteNote to *RouteNote

type RouteSummary

type RouteSummary struct {
	PointCount   int32
	FeatureCount int32
	Distance     int32
	ElapsedTime  int32

func NewRouteSummaryFromPB

func NewRouteSummaryFromPB(msg *pb.RouteSummary) *RouteSummary

transformer *pb.RouteSummary to *RouteSummary

type Service

type Service interface {
	GetFeature(ctx context.Context, latitude int32, longitude int32) (string, *Point, error)
	BroadcastHalfDuplex() chan Feature
	HalfDuplex(req *pb.Rectangle, stream pb.RouteGuide_HalfDuplexServer) error // half duplex (client request, server streams)
	ReverseHalfDuplex(stream pb.RouteGuide_ReverseHalfDuplexServer) error      // reverse half duplex (client streams, server responds)
	BroadcastFullDuplex() chan RouteNote
	FullDuplex(stream pb.RouteGuide_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