examplesrv

package
v0.0.0-...-bf737a8 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2019 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

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

It is generated from these files:

pb/examplesrv/service.proto

Index

Constants

View Source
const ServicePathPrefix = "/twirp/examplesrv.Service/"

ServicePathPrefix is used for all URL paths on a twirp Service server. Requests are always: POST ServicePathPrefix/method It can be used in an HTTP mux to route twirp requests along with non-twirp requests on other routes.

Variables

This section is empty.

Functions

func RegisterServiceServer

func RegisterServiceServer(s *grpc.Server, srv ServiceServer)

func WriteError

func WriteError(resp http.ResponseWriter, err error)

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)

Types

type Error

type Error struct {
	Code                 int32                       `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
	Message              string                      `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	Details              *any.Any                    `protobuf:"bytes,4,opt,name=details,proto3" json:"details,omitempty"`
	Validation           map[string]*ValidationError `` /* 161-byte string literal not displayed */
	XXX_NoUnkeyedLiteral struct{}                    `json:"-"`
	XXX_unrecognized     []byte                      `json:"-"`
	XXX_sizecache        int32                       `json:"-"`
}

func (*Error) Descriptor

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

func (*Error) GetCode

func (m *Error) GetCode() int32

func (*Error) GetDetails

func (m *Error) GetDetails() *any.Any

func (*Error) GetMessage

func (m *Error) GetMessage() string

func (*Error) GetValidation

func (m *Error) GetValidation() map[string]*ValidationError

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) Reset

func (m *Error) Reset()

func (*Error) String

func (m *Error) String() string

func (*Error) Validate

func (m *Error) Validate() error

Validate checks the field values on Error with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.

func (*Error) XXX_DiscardUnknown

func (m *Error) XXX_DiscardUnknown()

func (*Error) XXX_Marshal

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

func (*Error) XXX_Merge

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

func (*Error) XXX_Size

func (m *Error) XXX_Size() int

func (*Error) XXX_Unmarshal

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

type ErrorValidationError

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

ErrorValidationError is the validation error returned by Error.Validate if the designated constraints aren't met.

func (ErrorValidationError) Cause

func (e ErrorValidationError) Cause() error

Cause function returns cause value.

func (ErrorValidationError) Error

func (e ErrorValidationError) Error() string

Error satisfies the builtin error interface

func (ErrorValidationError) ErrorName

func (e ErrorValidationError) ErrorName() string

ErrorName returns error name.

func (ErrorValidationError) Field

func (e ErrorValidationError) Field() string

Field function returns field value.

func (ErrorValidationError) Key

func (e ErrorValidationError) Key() bool

Key function returns key value.

func (ErrorValidationError) Reason

func (e ErrorValidationError) Reason() string

Reason function returns reason value.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

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.

type Req

type Req struct {
	Str                  string   `protobuf:"bytes,1,opt,name=str,proto3" json:"str,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Req) Descriptor

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

func (*Req) GetStr

func (m *Req) GetStr() string

func (*Req) ProtoMessage

func (*Req) ProtoMessage()

func (*Req) Reset

func (m *Req) Reset()

func (*Req) String

func (m *Req) String() string

func (*Req) Validate

func (m *Req) Validate() error

Validate checks the field values on Req with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.

func (*Req) XXX_DiscardUnknown

func (m *Req) XXX_DiscardUnknown()

func (*Req) XXX_Marshal

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

func (*Req) XXX_Merge

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

func (*Req) XXX_Size

func (m *Req) XXX_Size() int

func (*Req) XXX_Unmarshal

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

type ReqValidationError

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

ReqValidationError is the validation error returned by Req.Validate if the designated constraints aren't met.

func (ReqValidationError) Cause

func (e ReqValidationError) Cause() error

Cause function returns cause value.

func (ReqValidationError) Error

func (e ReqValidationError) Error() string

Error satisfies the builtin error interface

func (ReqValidationError) ErrorName

func (e ReqValidationError) ErrorName() string

ErrorName returns error name.

func (ReqValidationError) Field

func (e ReqValidationError) Field() string

Field function returns field value.

func (ReqValidationError) Key

func (e ReqValidationError) Key() bool

Key function returns key value.

func (ReqValidationError) Reason

func (e ReqValidationError) Reason() string

Reason function returns reason value.

type Resp

type Resp struct {
	Str                  string   `protobuf:"bytes,1,opt,name=str,proto3" json:"str,omitempty"`
	Error                *Error   `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Resp) Descriptor

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

func (*Resp) GetError

func (m *Resp) GetError() *Error

func (*Resp) GetStr

func (m *Resp) GetStr() string

func (*Resp) ProtoMessage

func (*Resp) ProtoMessage()

func (*Resp) Reset

func (m *Resp) Reset()

func (*Resp) String

func (m *Resp) String() string

func (*Resp) Validate

func (m *Resp) Validate() error

Validate checks the field values on Resp with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.

func (*Resp) XXX_DiscardUnknown

func (m *Resp) XXX_DiscardUnknown()

func (*Resp) XXX_Marshal

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

func (*Resp) XXX_Merge

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

func (*Resp) XXX_Size

func (m *Resp) XXX_Size() int

func (*Resp) XXX_Unmarshal

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

type RespValidationError

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

RespValidationError is the validation error returned by Resp.Validate if the designated constraints aren't met.

func (RespValidationError) Cause

func (e RespValidationError) Cause() error

Cause function returns cause value.

func (RespValidationError) Error

func (e RespValidationError) Error() string

Error satisfies the builtin error interface

func (RespValidationError) ErrorName

func (e RespValidationError) ErrorName() string

ErrorName returns error name.

func (RespValidationError) Field

func (e RespValidationError) Field() string

Field function returns field value.

func (RespValidationError) Key

func (e RespValidationError) Key() bool

Key function returns key value.

func (RespValidationError) Reason

func (e RespValidationError) Reason() string

Reason function returns reason value.

type Service

type Service interface {
	Call(context.Context, *Req) (*Resp, error)
}

func NewServiceJSONClient

func NewServiceJSONClient(addr string, client HTTPClient) Service

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

func NewServiceProtobufClient

func NewServiceProtobufClient(addr string, client HTTPClient) Service

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

type ServiceClient

type ServiceClient interface {
	Call(ctx context.Context, in *Req, opts ...grpc.CallOption) (*Resp, error)
}

ServiceClient is the client API for Service service.

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

func NewServiceClient

func NewServiceClient(cc *grpc.ClientConn) ServiceClient

type ServiceServer

type ServiceServer interface {
	Call(context.Context, *Req) (*Resp, error)
}

ServiceServer is the server API for Service service.

type TwirpServer

type TwirpServer interface {
	http.Handler
	// ServiceDescriptor returns gzipped bytes describing the .proto file that
	// this service was generated from. Once unzipped, the bytes can be
	// unmarshalled as a
	// github.com/golang/protobuf/protoc-gen-go/descriptor.FileDescriptorProto.
	//
	// The returned integer is the index of this particular service within that
	// FileDescriptorProto's 'Service' slice of ServiceDescriptorProtos. This is a
	// low-level field, expected to be used for reflection.
	ServiceDescriptor() ([]byte, int)
	// ProtocGenTwirpVersion is the semantic version string of the version of
	// twirp used to generate this file.
	ProtocGenTwirpVersion() string
	// PathPrefix returns the HTTP URL path prefix for all methods handled by this
	// service. This can be used with an HTTP mux to route twirp requests
	// alongside non-twirp requests on one HTTP listener.
	PathPrefix() string
}

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.

func NewServiceServer

func NewServiceServer(svc Service, hooks *twirp.ServerHooks) TwirpServer

type UnimplementedServiceServer

type UnimplementedServiceServer struct {
}

UnimplementedServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedServiceServer) Call

func (*UnimplementedServiceServer) Call(ctx context.Context, req *Req) (*Resp, error)

type ValidationError

type ValidationError struct {
	Errors               []string `protobuf:"bytes,1,rep,name=errors,proto3" json:"errors,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*ValidationError) Descriptor

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

func (*ValidationError) GetErrors

func (m *ValidationError) GetErrors() []string

func (*ValidationError) ProtoMessage

func (*ValidationError) ProtoMessage()

func (*ValidationError) Reset

func (m *ValidationError) Reset()

func (*ValidationError) String

func (m *ValidationError) String() string

func (*ValidationError) Validate

func (m *ValidationError) Validate() error

Validate checks the field values on ValidationError with the rules defined in the proto definition for this message. If any rules are violated, an error is returned.

func (*ValidationError) XXX_DiscardUnknown

func (m *ValidationError) XXX_DiscardUnknown()

func (*ValidationError) XXX_Marshal

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

func (*ValidationError) XXX_Merge

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

func (*ValidationError) XXX_Size

func (m *ValidationError) XXX_Size() int

func (*ValidationError) XXX_Unmarshal

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

type ValidationErrorValidationError

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

ValidationErrorValidationError is the validation error returned by ValidationError.Validate if the designated constraints aren't met.

func (ValidationErrorValidationError) Cause

Cause function returns cause value.

func (ValidationErrorValidationError) Error

Error satisfies the builtin error interface

func (ValidationErrorValidationError) ErrorName

func (e ValidationErrorValidationError) ErrorName() string

ErrorName returns error name.

func (ValidationErrorValidationError) Field

Field function returns field value.

func (ValidationErrorValidationError) Key

Key function returns key value.

func (ValidationErrorValidationError) Reason

Reason function returns reason value.

Jump to

Keyboard shortcuts

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