notify

package
v0.0.0-...-564de18 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const NotifyServicePathPrefix = "/twirp/notify.NotifyService/"

NotifyServicePathPrefix is a convenience constant that may identify URL paths. Should be used with caution, it only matches routes generated by Twirp Go clients, with the default "/twirp" prefix and default CamelCase service and method names. More info: https://twitchtv.github.io/twirp/docs/routing.html

Variables

View Source
var File_rpc_notify_notify_proto protoreflect.FileDescriptor

Functions

func NewNotifyServiceGateway

func NewNotifyServiceGateway(svc NotifyService, hooks *twirp.ServerHooks) chi.Router

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 AuthRequest

type AuthRequest struct {
	Authorization string `protobuf:"bytes,1,opt,name=authorization,proto3" json:"authorization,omitempty"`
	// contains filtered or unexported fields
}

func (*AuthRequest) Descriptor deprecated

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

Deprecated: Use AuthRequest.ProtoReflect.Descriptor instead.

func (*AuthRequest) GetAuthorization

func (x *AuthRequest) GetAuthorization() string

func (*AuthRequest) ProtoMessage

func (*AuthRequest) ProtoMessage()

func (*AuthRequest) ProtoReflect

func (x *AuthRequest) ProtoReflect() protoreflect.Message

func (*AuthRequest) Reset

func (x *AuthRequest) Reset()

func (*AuthRequest) String

func (x *AuthRequest) String() string

type AuthResponse

type AuthResponse struct {
	UserID string `protobuf:"bytes,1,opt,name=userID,proto3" json:"userID,omitempty"`
	// contains filtered or unexported fields
}

func (*AuthResponse) Descriptor deprecated

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

Deprecated: Use AuthResponse.ProtoReflect.Descriptor instead.

func (*AuthResponse) GetUserID

func (x *AuthResponse) GetUserID() string

func (*AuthResponse) ProtoMessage

func (*AuthResponse) ProtoMessage()

func (*AuthResponse) ProtoReflect

func (x *AuthResponse) ProtoReflect() protoreflect.Message

func (*AuthResponse) Reset

func (x *AuthResponse) Reset()

func (*AuthResponse) String

func (x *AuthResponse) String() string

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 Handler

type Handler struct {
	sync.Mutex
	context.Context
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(ctx context.Context, id string, topics []string) *Handler

func (*Handler) Close

func (h *Handler) Close()

func (*Handler) Connect

func (h *Handler) Connect() error

func (*Handler) Incoming

func (*Handler) Incoming(msg []byte) error

func (*Handler) Outgoing

func (h *Handler) Outgoing() (<-chan []byte, error)

func (*Handler) Send

func (h *Handler) Send(msg interface{}) error

func (*Handler) SendRaw

func (h *Handler) SendRaw(msg []byte) error

type NotifyService

type NotifyService interface {
	// Auth request for websocket
	Auth(context.Context, *AuthRequest) (*AuthResponse, error)
}

func NewNotifyServiceJSONClient

func NewNotifyServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) NotifyService

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

func NewNotifyServiceProtobufClient

func NewNotifyServiceProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) NotifyService

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

type StatePayload

type StatePayload struct {
	Kind  string            `json:"kind"`
	State map[string]string `json:"state"`
}

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
	// google.golang.org/protobuf/types/descriptorpb.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.
	// The path prefix is in the form: "/<prefix>/<package>.<Service>/"
	// that is, everything in a Twirp route except for the <Method> at the end.
	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 NewNotifyServiceServer

func NewNotifyServiceServer(svc NotifyService, opts ...interface{}) TwirpServer

NewNotifyServiceServer builds a TwirpServer that can be used as an http.Handler to handle HTTP requests that are routed to the right method in the provided svc implementation. The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks).

Jump to

Keyboard shortcuts

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