Go API Documentation

github.com/titpetric/microservice/rpc/stats

Package stats is a generated twirp stub package. This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v5.10.0.

It is generated from these files: rpc/stats/stats.proto

Package

Files: 2. Third party imports: 7. Imports from organisation: 0. Tests: 0. Benchmarks: 0.

Constants

Vars

Reference imports to suppress errors if they are not otherwise used.

Types

HTTPClient

HTTPClient is the interface used by generated clients to send HTTP requests. It is fulfilled by *(net/http).Client, which is sufficient for most users. Users can provide their own implementation for special retry policies.

HTTPClient implementations should not follow redirects. Redirects are automatically disabled if *(net/http).Client is passed to client constructors. See the withoutRedirects function in this file for more details.

Field name Field type Comment
type

any

No comment on field.

PushRequest

This type doesn't have documentation.

Field name Field type Comment
Property

string

No comment on field.
Section

uint32

No comment on field.
Id

uint32

No comment on field.
XXX_NoUnkeyedLiteral

struct{}

No comment on field.
XXX_unrecognized

[]byte

No comment on field.
XXX_sizecache

int32

No comment on field.

PushResponse

This type doesn't have documentation.

Field name Field type Comment
XXX_NoUnkeyedLiteral

struct{}

No comment on field.
XXX_unrecognized

[]byte

No comment on field.
XXX_sizecache

int32

No comment on field.

StatsService

This type doesn't have documentation.

Field name Field type Comment
type

any

No comment on field.

StatsServiceClient

StatsServiceClient is the client API for StatsService service.

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

Field name Field type Comment
type

any

No comment on field.

StatsServiceServer

StatsServiceServer is the server API for StatsService service.

Field name Field type Comment
type

any

No comment on field.

TwirpServer

TwirpServer is the interface generated server structs will support: they're HTTP handlers with additional methods for accessing metadata about the service. Those accessors are a low-level API for building reflection tools. Most people can think of TwirpServers as just http.Handlers.

Field name Field type Comment
type

any

No comment on field.

UnimplementedStatsServiceServer

UnimplementedStatsServiceServer can be embedded to have forward compatible implementations.

internalWithCause

internalWithCause is a Twirp Internal error wrapping an original error cause, accessible by github.com/pkg/errors.Cause, but the original error message is not exposed on Msg().

Field name Field type Comment
msg

string

No comment on field.
cause

error

No comment on field.

statsServiceClient

This type doesn't have documentation.

Field name Field type Comment
cc

*grpc.ClientConn

No comment on field.

statsServiceJSONClient

This type doesn't have documentation.

Field name Field type Comment
client

HTTPClient

No comment on field.
urls

[]string

No comment on field.
opts

twirp.ClientOptions

No comment on field.

statsServiceProtobufClient

This type doesn't have documentation.

Field name Field type Comment
client

HTTPClient

No comment on field.
urls

[]string

No comment on field.
opts

twirp.ClientOptions

No comment on field.

statsServiceServer

This type doesn't have documentation.

Field name Field type Comment

StatsService

No comment on field.
hooks

*twirp.ServerHooks

No comment on field.

twerrJSON

JSON serialization for errors

Field name Field type Comment
Code

string

No comment on field.
Msg

string

No comment on field.
Meta

map[string]string

No comment on field.

wrappedError

This type doesn't have documentation.

Field name Field type Comment
prefix

string

No comment on field.
cause

error

No comment on field.

Functions

func NewStatsServiceClient

func NewStatsServiceJSONClient

NewStatsServiceJSONClient creates a JSON client that implements the StatsService interface. It communicates using JSON and can be configured with a custom HTTPClient.

Uses: http.Client, twirp.ClientOptions.

func NewStatsServiceProtobufClient

NewStatsServiceProtobufClient creates a Protobuf client that implements the StatsService interface. It communicates using Protobuf and can be configured with a custom HTTPClient.

Uses: http.Client, twirp.ClientOptions.

func NewStatsServiceServer

func RegisterStatsServiceServer

func WriteError

WriteError writes an HTTP response with a valid Twirp error format (code, msg, meta). Useful outside of the Twirp server (e.g. http middleware), but does not trigger hooks. If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)

Uses: context.Background.

func (*PushRequest) Descriptor

func (*PushRequest) GetId

func (*PushRequest) GetProperty

func (*PushRequest) GetSection

func (*PushRequest) ProtoMessage

func (*PushRequest) Reset

func (*PushRequest) String

Uses: proto.CompactTextString.

func (*PushRequest) XXX_DiscardUnknown

func (*PushRequest) XXX_Marshal

func (*PushRequest) XXX_Merge

func (*PushRequest) XXX_Size

func (*PushRequest) XXX_Unmarshal

func (*PushResponse) Descriptor

func (*PushResponse) ProtoMessage

func (*PushResponse) Reset

func (*PushResponse) String

Uses: proto.CompactTextString.

func (*PushResponse) XXX_DiscardUnknown

func (*PushResponse) XXX_Marshal

func (*PushResponse) XXX_Merge

func (*PushResponse) XXX_Size

func (*PushResponse) XXX_Unmarshal

func (*UnimplementedStatsServiceServer) Push

Uses: codes.Unimplemented, status.Errorf.

func (*internalWithCause) Cause

func (*internalWithCause) Code

Uses: twirp.Internal.

func (*internalWithCause) Error

func (*internalWithCause) Meta

func (*internalWithCause) MetaMap

func (*internalWithCause) Msg

func (*internalWithCause) WithMeta

func (*statsServiceClient) Push

func (*statsServiceJSONClient) Push

Uses: ctxsetters.WithMethodName, ctxsetters.WithPackageName, ctxsetters.WithServiceName, twirp.Error, twirp.InternalErrorWith.

func (*statsServiceProtobufClient) Push

Uses: ctxsetters.WithMethodName, ctxsetters.WithPackageName, ctxsetters.WithServiceName, twirp.Error, twirp.InternalErrorWith.

func (*statsServiceServer) PathPrefix

func (*statsServiceServer) ProtocGenTwirpVersion

func (*statsServiceServer) ServeHTTP

Uses: ctxsetters.WithPackageName, ctxsetters.WithResponseWriter, ctxsetters.WithServiceName, fmt.Sprintf.

func (*statsServiceServer) ServiceDescriptor

func (*wrappedError) Cause

func (*wrappedError) Error

Private functions

func badRouteError

badRouteError is used when the twirp server cannot route a request

References: twirp.BadRoute, twirp.NewError.

func callClientError

func callClientRequestPrepared

func callClientResponseReceived

func callError

Call twirp.ServerHooks.Error if the hook is available

func callRequestReceived

Call twirp.ServerHooks.RequestReceived if the hook is available

func callRequestRouted

Call twirp.ServerHooks.RequestRouted if the hook is available

func callResponsePrepared

Call twirp.ServerHooks.ResponsePrepared if the hook is available

func callResponseSent

Call twirp.ServerHooks.ResponseSent if the hook is available

func doJSONRequest

doJSONRequest makes a JSON request to the remote Twirp service.

References: bytes.NewBuffer, jsonpb.Marshaler, jsonpb.Unmarshaler.

func doProtobufRequest

doProtobufRequest makes a Protobuf request to the remote Twirp service.

References: bytes.NewBuffer, ioutil.ReadAll, proto.Marshal, proto.Unmarshal.

func ensurePanicResponses

ensurePanicResponses makes sure that rpc methods causing a panic still result in a Twirp Internal error response (status 500), and error hooks are properly called with the panic wrapped as an error. The panic is re-raised so it can be handled normally with middleware.

References: http.Flusher.

func errFromPanic

errFromPanic returns the typed error if the recovered panic is an error, otherwise formats as error.

References: fmt.Errorf.

func errorFromResponse

errorFromResponse builds a twirp.Error from a non-200 HTTP response. If the response has a valid serialized Twirp error, then it's returned. If not, the response status code is used to generate a similar twirp error. See twirpErrorFromIntermediary for more info on intermediary errors.

References: bytes.NewReader, fmt.Sprintf, http.StatusText, ioutil.ReadAll, json.NewDecoder, twirp.ErrorCode, twirp.InternalError, twirp.IsValidErrorCode, twirp.NewError.

func getCustomHTTPReqHeaders

getCustomHTTPReqHeaders retrieves a copy of any headers that are set in a context through the twirp.WithHTTPRequestHeaders function. If there are no headers set, or if they have the wrong type, nil is returned.

References: http.Header, twirp.HTTPRequestHeaders.

func init

References: proto.RegisterType.

func isHTTPRedirect

func malformedRequestError

malformedRequestError is used when the twirp server cannot unmarshal a request

References: twirp.Malformed, twirp.NewError.

func marshalErrorToJSON

marshalErrorToJSON returns JSON from a twirp.Error, that can be used as HTTP error response body. If serialization fails, it will use a descriptive Internal error instead.

References: json.Marshal, twirp.Internal.

func newRequest

newRequest makes an http.Request from a client, adding common headers.

References: http.NewRequest.

func twirpErrorFromIntermediary

twirpErrorFromIntermediary maps HTTP errors from non-twirp sources to twirp errors. The mapping is similar to gRPC: https://github.com/grpc/grpc/blob/master/doc/http-grpc-status-mapping.md. Returned twirp Errors have some additional metadata for inspection.

References: strconv.Itoa, twirp.BadRoute, twirp.ErrorCode, twirp.Internal, twirp.NewError, twirp.PermissionDenied, twirp.Unauthenticated, twirp.Unavailable, twirp.Unknown.

func urlBase

urlBase helps ensure that addr specifies a scheme. If it is unparsable as a URL, it returns addr unchanged.

References: url.Parse.

func withoutRedirects

withoutRedirects makes sure that the POST request can not be redirected. The standard library will, by default, redirect requests (including POSTs) if it gets a 302 or 303 response, and also 301s in go1.8. It redirects by making a second request, changing the method to GET and removing the body. This produces very confusing error messages, so instead we set a redirect policy that always errors. This stops Go from executing the redirect.

We have to be a little careful in case the user-provided http.Client has its own CheckRedirect policy - if so, we'll run through that policy first.

Because this requires modifying the http.Client, we make a new copy of the client and return it.

References: http.ErrUseLastResponse, http.Request.

func wrapInternal

wrapInternal wraps an error with a prefix as an Internal error. The original error cause is accessible by github.com/pkg/errors.Cause.

References: twirp.InternalErrorWith.

func writeError

writeError writes Twirp errors in the response and triggers hooks.

References: ctxsetters.WithStatusCode, strconv.Itoa, twirp.Error, twirp.InternalErrorWith, twirp.ServerHTTPStatusFromErrorCode.

func servePush

References: fmt.Sprintf, strings.Index, strings.ToLower, strings.TrimSpace.

func servePushJSON

References: bytes.Buffer, ctxsetters.WithMethodName, ctxsetters.WithStatusCode, fmt.Sprintf, http.StatusOK, jsonpb.Marshaler, jsonpb.Unmarshaler, strconv.Itoa, twirp.InternalError, twirp.NewError, twirp.Unknown.

func servePushProtobuf

References: ctxsetters.WithMethodName, ctxsetters.WithStatusCode, fmt.Sprintf, http.StatusOK, ioutil.ReadAll, proto.Marshal, proto.Unmarshal, strconv.Itoa, twirp.InternalError, twirp.NewError, twirp.Unknown.

func writeError

writeError writes an HTTP response with a valid Twirp error format, and triggers hooks. If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)