service

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Close() error
	GetID() string
	Send(*pb.TheRequest) (*pb.TheResponse, error)
}

Client is an abstraction representing a client connection to each downstream service.

func MakeFireAndForget

func MakeFireAndForget(client Client) Client

MakeFireAndForget creates a new Client that will send requests and not wait for a response.

type Config

type Config struct {
	ID                          string
	GRPCServerPort              int
	H1ServerPort                int
	GRPCDownstreamServers       []string
	GRPCProxy                   string
	H1DownstreamServers         []string
	PercentageFailedRequests    int
	SleepInMillis               int
	TerminateAfter              int
	FireAndForget               bool
	DownstreamConnectionTimeout time.Duration
	ExtraArguments              map[string]string
}

Config holds the ,ain configuration for this service.

type MockClient

type MockClient struct {
	IDToReturn         string
	ResponseToReturn   *pb.TheResponse
	ErrorToReturn      error
	RequestReceived    *pb.TheRequest
	RequestInterceptor func(req *pb.TheRequest)
	CloseWasCalled     bool
}

func (*MockClient) Close

func (m *MockClient) Close() error

func (*MockClient) GetID

func (m *MockClient) GetID() string

func (*MockClient) Send

func (m *MockClient) Send(req *pb.TheRequest) (*pb.TheResponse, error)

type MockServer

type MockServer struct {
	IDToReturn string
}

func (MockServer) GetID

func (m MockServer) GetID() string

func (MockServer) Shutdown added in v0.0.2

func (m MockServer) Shutdown() error

type MockStrategy

type MockStrategy struct {
	ContextReceived  context.Context
	RequestReceived  *pb.TheRequest
	ResponseToReturn *pb.TheResponse
	ErrorToReturn    error
}

func (*MockStrategy) Do

type RequestHandler

type RequestHandler struct {
	Strategy Strategy // public due to circular dependency between server and strategy
	// contains filtered or unexported fields
}

RequestHandler is a protocol-independent request/response handler interface

func NewRequestHandler added in v0.0.2

func NewRequestHandler(config *Config) *RequestHandler

func (*RequestHandler) ConfigID added in v0.0.2

func (h *RequestHandler) ConfigID() string

func (*RequestHandler) Handle

func (h *RequestHandler) Handle(ctx context.Context, req *pb.TheRequest) (*pb.TheResponse, error)

Handle takes in a request, processes it accordingly to its Strategy, an returns the response.

func (*RequestHandler) Stopping added in v0.0.2

func (h *RequestHandler) Stopping() <-chan struct{}

type Server

type Server interface {
	GetID() string
	Shutdown() error
}

Server is an abstraction representing each server made available to receive inbound connections.

type Service

type Service struct {
	Servers  []Server
	Clients  []Client
	Strategy Strategy
}

Service is the aggregate of all Client, Server, and the Strategy.

func (*Service) Close

func (s *Service) Close() error

Close closes any open connections with Clients.

type Strategy

type Strategy interface {
	Do(context.Context, *pb.TheRequest) (*pb.TheResponse, error)
}

Strategy is the algorithm applied by this service when it receives requests (c.f. http://wiki.c2.com/?StrategyPattern)

Jump to

Keyboard shortcuts

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