factory

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: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeGetBoxesHTTPHandler

func MakeGetBoxesHTTPHandler(ep endpoint.Endpoint, logger log.Logger, options ...kitHTTP.ServerOption) *kitHTTP.Server

func MakeMakeBoxHTTPHandler

func MakeMakeBoxHTTPHandler(ep endpoint.Endpoint, logger log.Logger, options ...kitHTTP.ServerOption) *kitHTTP.Server

func MakeStatusHTTPHandler

func MakeStatusHTTPHandler(ep endpoint.Endpoint, logger log.Logger, options ...kitHTTP.ServerOption) *kitHTTP.Server

func NewClient

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

func NewPBFromBoolValue

func NewPBFromBoolValue(msg *BoolValue) *pb.BoolValue

transformer *BoolValue to *pb.BoolValue

func NewPBFromBoxSpecification

func NewPBFromBoxSpecification(msg *BoxSpecification) *pb.BoxSpecification

transformer *BoxSpecification to *pb.BoxSpecification

func NewPBFromBoxes

func NewPBFromBoxes(msg *Boxes) *pb.Boxes

transformer *Boxes to *pb.Boxes

func NewPBFromEmpty

func NewPBFromEmpty(msg *Empty) *pb.Empty

transformer *Empty to *pb.Empty

func NewPBFromStatusMessage

func NewPBFromStatusMessage(msg *StatusMessage) *pb.StatusMessage

transformer *StatusMessage to *pb.StatusMessage

func NewPBFromStringValue

func NewPBFromStringValue(msg *StringValue) *pb.StringValue

transformer *StringValue to *pb.StringValue

func RegisterHandlers

func RegisterHandlers(router *mux.Router, endpoints Endpoints, logger log.Logger, options ...kitHTTP.ServerOption)

Types

type BoolValue

type BoolValue struct {
	Value bool
}

func NewBoolValueFromPB

func NewBoolValueFromPB(msg *pb.BoolValue) *BoolValue

transformer *pb.BoolValue to *BoolValue

type BoxSpecification

type BoxSpecification struct {
	Name   string
	Height int32
	Width  int32
	Depth  int32
}

func NewBoxSpecificationFromPB

func NewBoxSpecificationFromPB(msg *pb.BoxSpecification) *BoxSpecification

transformer *pb.BoxSpecification to *BoxSpecification

type Boxes

type Boxes struct {
	Boxes []BoxSpecification
}

func NewBoxesFromPB

func NewBoxesFromPB(msg *pb.Boxes) *Boxes

transformer *pb.Boxes to *Boxes

type Empty

type Empty struct {
	Page    int32
	PerPage int32
}

func NewEmptyFromPB

func NewEmptyFromPB(msg *pb.Empty) *Empty

transformer *pb.Empty to *Empty

type Endpoints

type Endpoints struct {
	MakeBoxEndpoint  endpoint.Endpoint
	GetBoxesEndpoint endpoint.Endpoint
	StatusEndpoint   endpoint.Endpoint
}

func MakeEndpoints

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

type GRPCServer

type GRPCServer struct {
	MakeBoxGRPCHandler  kitGRPC.Handler
	GetBoxesGRPCHandler kitGRPC.Handler
	StatusGRPCHandler   kitGRPC.Handler
	// contains filtered or unexported fields
}

func NewGRPCServer

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

func (*GRPCServer) GetBoxes

func (s *GRPCServer) GetBoxes(ctx context.Context, req *pb.Empty) (*pb.Boxes, error)

protobuf implementation : no streaming for GetBoxes

func (*GRPCServer) MakeBox

func (s *GRPCServer) MakeBox(ctx context.Context, req *pb.BoxSpecification) (*pb.Empty, error)

protobuf implementation : no streaming for MakeBox

func (*GRPCServer) Status

func (s *GRPCServer) Status(ctx context.Context, req *pb.Empty) (*pb.StatusMessage, error)

protobuf implementation : no streaming for Status

type Repository

type Repository interface {
	MakeBox(ctx context.Context, name string, height int32, width int32, depth int32) (int32, int32, error)
	GetBoxes(ctx context.Context, page int32, perPage int32) ([]BoxSpecification, error)
	Status(ctx context.Context, page int32, perPage int32) (string, bool, error)
}

*

type MysqlConfig struct {
	Host              string `env:"DB_READ_HOST" envDefault:"local-factory"`
	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:"factory"`
}

* *

*

func NewRepository

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

type Service

type Service interface {
	MakeBox(ctx context.Context, name string, height int32, width int32, depth int32) (int32, int32, error)
	GetBoxes(ctx context.Context, page int32, perPage int32) ([]BoxSpecification, error)
	Status(ctx context.Context, page int32, perPage int32) (string, bool, error)
	Log() log.Logger
}

func NewHTTPClient

func NewHTTPClient(serverAddr string, logger log.Logger, options ...kitHTTP.ClientOption) (Service, error)

func NewService

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

type StatusMessage

type StatusMessage struct {
	ServiceName string
	Ok          bool
}

func NewStatusMessageFromPB

func NewStatusMessageFromPB(msg *pb.StatusMessage) *StatusMessage

transformer *pb.StatusMessage to *StatusMessage

type StringValue

type StringValue struct {
	Value     string
	Timestamp timestamp.Timestamp
}

func NewStringValueFromPB

func NewStringValueFromPB(msg *pb.StringValue) *StringValue

transformer *pb.StringValue to *StringValue

Jump to

Keyboard shortcuts

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