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
- func RegisterServiceServer(s *grpc.Server, srv ServiceServer)
- func WriteError(resp http.ResponseWriter, err error)
- type Error
- func (*Error) Descriptor() ([]byte, []int)
- func (m *Error) GetCode() int32
- func (m *Error) GetDetails() *any.Any
- func (m *Error) GetMessage() string
- func (m *Error) GetValidation() map[string]*ValidationError
- func (*Error) ProtoMessage()
- func (m *Error) Reset()
- func (m *Error) String() string
- func (m *Error) Validate() error
- func (m *Error) XXX_DiscardUnknown()
- func (m *Error) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Error) XXX_Merge(src proto.Message)
- func (m *Error) XXX_Size() int
- func (m *Error) XXX_Unmarshal(b []byte) error
- type ErrorValidationError
- type HTTPClient
- type Req
- func (*Req) Descriptor() ([]byte, []int)
- func (m *Req) GetStr() string
- func (*Req) ProtoMessage()
- func (m *Req) Reset()
- func (m *Req) String() string
- func (m *Req) Validate() error
- func (m *Req) XXX_DiscardUnknown()
- func (m *Req) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Req) XXX_Merge(src proto.Message)
- func (m *Req) XXX_Size() int
- func (m *Req) XXX_Unmarshal(b []byte) error
- type ReqValidationError
- type Resp
- func (*Resp) Descriptor() ([]byte, []int)
- func (m *Resp) GetError() *Error
- func (m *Resp) GetStr() string
- func (*Resp) ProtoMessage()
- func (m *Resp) Reset()
- func (m *Resp) String() string
- func (m *Resp) Validate() error
- func (m *Resp) XXX_DiscardUnknown()
- func (m *Resp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Resp) XXX_Merge(src proto.Message)
- func (m *Resp) XXX_Size() int
- func (m *Resp) XXX_Unmarshal(b []byte) error
- type RespValidationError
- type Service
- type ServiceClient
- type ServiceServer
- type TwirpServer
- type UnimplementedServiceServer
- type ValidationError
- func (*ValidationError) Descriptor() ([]byte, []int)
- func (m *ValidationError) GetErrors() []string
- func (*ValidationError) ProtoMessage()
- func (m *ValidationError) Reset()
- func (m *ValidationError) String() string
- func (m *ValidationError) Validate() error
- func (m *ValidationError) XXX_DiscardUnknown()
- func (m *ValidationError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ValidationError) XXX_Merge(src proto.Message)
- func (m *ValidationError) XXX_Size() int
- func (m *ValidationError) XXX_Unmarshal(b []byte) error
- type ValidationErrorValidationError
- func (e ValidationErrorValidationError) Cause() error
- func (e ValidationErrorValidationError) Error() string
- func (e ValidationErrorValidationError) ErrorName() string
- func (e ValidationErrorValidationError) Field() string
- func (e ValidationErrorValidationError) Key() bool
- func (e ValidationErrorValidationError) Reason() string
Constants ¶
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) GetDetails ¶
func (*Error) GetMessage ¶
func (*Error) GetValidation ¶
func (m *Error) GetValidation() map[string]*ValidationError
func (*Error) ProtoMessage ¶
func (*Error) ProtoMessage()
func (*Error) Validate ¶
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 (*Error) XXX_Unmarshal ¶
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 ¶
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) ProtoMessage ¶
func (*Req) ProtoMessage()
func (*Req) Validate ¶
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_Unmarshal ¶
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) ProtoMessage ¶
func (*Resp) ProtoMessage()
func (*Resp) Validate ¶
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_Unmarshal ¶
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 ¶
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 ¶
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.
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 ¶
func (e ValidationErrorValidationError) Cause() error
Cause function returns cause value.
func (ValidationErrorValidationError) Error ¶
func (e ValidationErrorValidationError) Error() string
Error satisfies the builtin error interface
func (ValidationErrorValidationError) ErrorName ¶
func (e ValidationErrorValidationError) ErrorName() string
ErrorName returns error name.
func (ValidationErrorValidationError) Field ¶
func (e ValidationErrorValidationError) Field() string
Field function returns field value.
func (ValidationErrorValidationError) Key ¶
func (e ValidationErrorValidationError) Key() bool
Key function returns key value.
func (ValidationErrorValidationError) Reason ¶
func (e ValidationErrorValidationError) Reason() string
Reason function returns reason value.