drudge

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2019 License: GPL-3.0 Imports: 44 Imported by: 0

README

Drudge RPC Server

Drudge is a developing server library to help with running an RPC/HTTP service. Some of the main features:

  • Opencensus Telemetry
  • RPC and HTTP Support
  • Middleware Injection
  • Structured Logging

Documentation

Index

Constants

View Source
const (
	GoogleProjectID      = "GCE_PROJECT_ID"
	GoogleServiceAccount = "GCE_SERVICE_ACCOUNT"
)

Variables

View Source
var (
	ErrInvalidLengthServer = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowServer   = fmt.Errorf("proto: integer overflow")
)
View Source
var (
	LatencyTag, _  = tag.NewKey("latency")
	ErrorTag, _    = tag.NewKey("error")
	EndpointTag, _ = tag.NewKey("endpoint")
	MethodTag, _   = tag.NewKey("method")
	StatusTag, _   = tag.NewKey("status")
	ServiceTag, _  = tag.NewKey("service")

	LatencyDistribution = view.Distribution(25, 50, 75, 100, 200, 400, 600, 800, 1000, 2000, 4000, 6000)
)

Functions

func ForwardResponseStream

func ForwardResponseStream(
	ctx context.Context,
	mux *runtime.ServeMux,
	marshaler runtime.Marshaler,
	w http.ResponseWriter,
	req *http.Request,
	recv func() (goproto.Message, error), opts ...func(context.Context, http.ResponseWriter, goproto.Message) error,
)

ForwardResponseStream forwards the stream from gRPC server to REST client.

func Jaeger

func Jaeger(c interface{}) (func(), error)

func MeasureFloat

func MeasureFloat(ctx context.Context, m *stats.Float64Measure, v float64, tags ...tag.Mutator)

func MeasureInt

func MeasureInt(ctx context.Context, m *stats.Int64Measure, v int64, tags ...tag.Mutator)

func Run

func Run(ctx context.Context, opts Options) error

Types

type Endpoint

type Endpoint struct {
	Network string
	Addr    string
}

Endpoint describes a gRPC endpoint

type JaegerConfig

type JaegerConfig struct {
	ServiceName string
}

type Options

type Options struct {
	// BasePath is the root path that the HTTP service listens on
	BasePath string

	// Addr is the address to listen
	Addr string

	// GRPCServer defines an endpoint of a gRPC service
	RPC Endpoint

	// Defines the RPC Clients to pass requests through
	Handlers []Handler

	// SwaggerDir is a path to a directory from which the server
	// serves swagger specs.
	SwaggerDir string

	// Mux is a list of options to be passed to the grpc-gateway multiplexer
	Mux []gwruntime.ServeMuxOption

	OnRegister func(server *grpc.Server) error

	TraceExporter TraceExporter
	TraceConfig   interface{}

	Metrics *RegistryHandler
}

Options is a set of options to be passed to Run

type RegistryHandler

type RegistryHandler struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*RegistryHandler) Float64Measure

func (r *RegistryHandler) Float64Measure(
	name,
	description,
	unit string,
	tags []tag.Key,
	aggregate *view.Aggregation,
) *stats.Float64Measure

Float64Measure establishes a new OpenCensus Floating Point Metric based on the provided information and registers a configured stats.View.

func (*RegistryHandler) Int64Measure

func (r *RegistryHandler) Int64Measure(
	name,
	description,
	unit string,
	tags []tag.Key,
	aggregate *view.Aggregation,
) *stats.Int64Measure

Int64Measure establishes a new OpenCensus Integer Metric based on the provided information and registers a configured stats.View.

func (*RegistryHandler) Metrics

func (r *RegistryHandler) Metrics() map[string]interface{}

func (*RegistryHandler) ServeHTTP

func (r *RegistryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type StreamError

type StreamError struct {
	GrpcCode   int32        `protobuf:"varint,1,opt,name=grpc_code,json=grpcCode,proto3" json:"grpc_code,omitempty"`
	HttpCode   int32        `protobuf:"varint,2,opt,name=http_code,json=httpCode,proto3" json:"http_code,omitempty"`
	Message    string       `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
	HttpStatus string       `protobuf:"bytes,4,opt,name=http_status,json=httpStatus,proto3" json:"http_status,omitempty"`
	Details    []*types.Any `protobuf:"bytes,5,rep,name=details,proto3" json:"details,omitempty"`
}

StreamError is a response type which is returned when streaming rpc returns an error.

func (*StreamError) Descriptor

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

func (*StreamError) Equal

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

func (*StreamError) GetDetails

func (m *StreamError) GetDetails() []*types.Any

func (*StreamError) GetGrpcCode

func (m *StreamError) GetGrpcCode() int32

func (*StreamError) GetHttpCode

func (m *StreamError) GetHttpCode() int32

func (*StreamError) GetHttpStatus

func (m *StreamError) GetHttpStatus() string

func (*StreamError) GetMessage

func (m *StreamError) GetMessage() string

func (*StreamError) GoString

func (this *StreamError) GoString() string

func (*StreamError) Marshal

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

func (*StreamError) MarshalTo

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

func (*StreamError) ProtoMessage

func (*StreamError) ProtoMessage()

func (*StreamError) Reset

func (m *StreamError) Reset()

func (*StreamError) Size

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

func (*StreamError) String

func (this *StreamError) String() string

func (*StreamError) Unmarshal

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

func (*StreamError) XXX_DiscardUnknown

func (m *StreamError) XXX_DiscardUnknown()

func (*StreamError) XXX_Marshal

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

func (*StreamError) XXX_Merge

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

func (*StreamError) XXX_Size

func (m *StreamError) XXX_Size() int

func (*StreamError) XXX_Unmarshal

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

type TraceExporter

type TraceExporter func(interface{}) (func(), error)

Jump to

Keyboard shortcuts

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