Help us shape the future of Go! Take the 2026 Go Developer Survey

frontend

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2020 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthFrontend = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowFrontend   = fmt.Errorf("proto: integer overflow")
)

Functions

func RegisterFrontendServer

func RegisterFrontendServer(s *grpc.Server, srv FrontendServer)

Types

type Config

type Config struct {
	MaxOutstandingPerTenant int           `yaml:"max_outstanding_per_tenant"`
	CompressResponses       bool          `yaml:"compress_responses"`
	DownstreamURL           string        `yaml:"downstream"`
	LogQueriesLongerThan    time.Duration `yaml:"log_queries_longer_than"`
}

Config for a Frontend.

func (*Config) RegisterFlags

func (cfg *Config) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet.

type Frontend

type Frontend struct {
	// contains filtered or unexported fields
}

Frontend queues HTTP requests, dispatches them to backends, and handles retries for requests which failed.

func New

func New(cfg Config, log log.Logger) (*Frontend, error)

New creates a new frontend.

func (*Frontend) Close

func (f *Frontend) Close()

Close stops new requests and errors out any pending requests.

func (*Frontend) Handler

func (f *Frontend) Handler() http.Handler

Handler for HTTP requests.

func (*Frontend) Process

func (f *Frontend) Process(server Frontend_ProcessServer) error

Process allows backends to pull requests from the frontend.

func (*Frontend) RoundTrip

func (f *Frontend) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip implement http.Transport.

func (*Frontend) RoundTripGRPC

func (f *Frontend) RoundTripGRPC(ctx context.Context, req *ProcessRequest) (*ProcessResponse, error)

RoundTripGRPC round trips a proto (instead of a HTTP request).

func (*Frontend) Wrap added in v0.4.0

func (f *Frontend) Wrap(trw Tripperware)

Wrap uses a Tripperware to chain a new RoundTripper to the frontend.

type FrontendClient

type FrontendClient interface {
	Process(ctx context.Context, opts ...grpc.CallOption) (Frontend_ProcessClient, error)
}

FrontendClient is the client API for Frontend service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewFrontendClient

func NewFrontendClient(cc *grpc.ClientConn) FrontendClient

type FrontendServer

type FrontendServer interface {
	Process(Frontend_ProcessServer) error
}

FrontendServer is the server API for Frontend service.

type Frontend_ProcessClient

type Frontend_ProcessClient interface {
	Send(*ProcessResponse) error
	Recv() (*ProcessRequest, error)
	grpc.ClientStream
}

type Frontend_ProcessServer

type Frontend_ProcessServer interface {
	Send(*ProcessRequest) error
	Recv() (*ProcessResponse, error)
	grpc.ServerStream
}

type ProcessRequest

type ProcessRequest struct {
	HttpRequest *httpgrpc.HTTPRequest `protobuf:"bytes,1,opt,name=httpRequest,proto3" json:"httpRequest,omitempty"`
}

func (*ProcessRequest) Descriptor

func (*ProcessRequest) Descriptor() ([]byte, []int)

func (*ProcessRequest) Equal

func (this *ProcessRequest) Equal(that interface{}) bool

func (*ProcessRequest) GetHttpRequest

func (m *ProcessRequest) GetHttpRequest() *httpgrpc.HTTPRequest

func (*ProcessRequest) GoString

func (this *ProcessRequest) GoString() string

func (*ProcessRequest) Marshal

func (m *ProcessRequest) Marshal() (dAtA []byte, err error)

func (*ProcessRequest) MarshalTo

func (m *ProcessRequest) MarshalTo(dAtA []byte) (int, error)

func (*ProcessRequest) ProtoMessage

func (*ProcessRequest) ProtoMessage()

func (*ProcessRequest) Reset

func (m *ProcessRequest) Reset()

func (*ProcessRequest) Size

func (m *ProcessRequest) Size() (n int)

func (*ProcessRequest) String

func (this *ProcessRequest) String() string

func (*ProcessRequest) Unmarshal

func (m *ProcessRequest) Unmarshal(dAtA []byte) error

func (*ProcessRequest) XXX_DiscardUnknown

func (m *ProcessRequest) XXX_DiscardUnknown()

func (*ProcessRequest) XXX_Marshal

func (m *ProcessRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ProcessRequest) XXX_Merge

func (m *ProcessRequest) XXX_Merge(src proto.Message)

func (*ProcessRequest) XXX_Size

func (m *ProcessRequest) XXX_Size() int

func (*ProcessRequest) XXX_Unmarshal

func (m *ProcessRequest) XXX_Unmarshal(b []byte) error

type ProcessResponse

type ProcessResponse struct {
	HttpResponse *httpgrpc.HTTPResponse `protobuf:"bytes,1,opt,name=httpResponse,proto3" json:"httpResponse,omitempty"`
}

func (*ProcessResponse) Descriptor

func (*ProcessResponse) Descriptor() ([]byte, []int)

func (*ProcessResponse) Equal

func (this *ProcessResponse) Equal(that interface{}) bool

func (*ProcessResponse) GetHttpResponse

func (m *ProcessResponse) GetHttpResponse() *httpgrpc.HTTPResponse

func (*ProcessResponse) GoString

func (this *ProcessResponse) GoString() string

func (*ProcessResponse) Marshal

func (m *ProcessResponse) Marshal() (dAtA []byte, err error)

func (*ProcessResponse) MarshalTo

func (m *ProcessResponse) MarshalTo(dAtA []byte) (int, error)

func (*ProcessResponse) ProtoMessage

func (*ProcessResponse) ProtoMessage()

func (*ProcessResponse) Reset

func (m *ProcessResponse) Reset()

func (*ProcessResponse) Size

func (m *ProcessResponse) Size() (n int)

func (*ProcessResponse) String

func (this *ProcessResponse) String() string

func (*ProcessResponse) Unmarshal

func (m *ProcessResponse) Unmarshal(dAtA []byte) error

func (*ProcessResponse) XXX_DiscardUnknown

func (m *ProcessResponse) XXX_DiscardUnknown()

func (*ProcessResponse) XXX_Marshal

func (m *ProcessResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ProcessResponse) XXX_Merge

func (m *ProcessResponse) XXX_Merge(src proto.Message)

func (*ProcessResponse) XXX_Size

func (m *ProcessResponse) XXX_Size() int

func (*ProcessResponse) XXX_Unmarshal

func (m *ProcessResponse) XXX_Unmarshal(b []byte) error

type RoundTripFunc added in v0.2.0

type RoundTripFunc func(*http.Request) (*http.Response, error)

RoundTripFunc is to http.RoundTripper what http.HandlerFunc is to http.Handler.

func (RoundTripFunc) RoundTrip added in v0.2.0

func (f RoundTripFunc) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper.

type Tripperware added in v0.4.0

type Tripperware func(http.RoundTripper) http.RoundTripper

Tripperware is a signature for all http client-side middleware.

type Worker

type Worker interface {
	Stop()
}

Worker is the counter-part to the frontend, actually processing requests.

func NewWorker

func NewWorker(cfg WorkerConfig, server *server.Server, log log.Logger) (Worker, error)

NewWorker creates a new Worker.

type WorkerConfig

type WorkerConfig struct {
	Address           string
	Parallelism       int
	DNSLookupDuration time.Duration

	GRPCClientConfig grpcclient.Config `yaml:"grpc_client_config"`
}

WorkerConfig is config for a worker.

func (*WorkerConfig) RegisterFlags

func (cfg *WorkerConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet.

Jump to

Keyboard shortcuts

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