protocol

package
v0.0.0-...-bee86e5 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const PhotoFramePathPrefix = "/twirp/protocol.PhotoFrame/"

PhotoFramePathPrefix 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 (
	SetGridReq_OldImageAction_name = map[int32]string{
		0: "OLD_IMAGE_KEEP",
		1: "OLD_IMAGE_WIPE",
		2: "OLD_IMAGE_FADE",
	}
	SetGridReq_OldImageAction_value = map[string]int32{
		"OLD_IMAGE_KEEP": 0,
		"OLD_IMAGE_WIPE": 1,
		"OLD_IMAGE_FADE": 2,
	}
)

Enum value maps for SetGridReq_OldImageAction.

View Source
var File_photo_frame_proto protoreflect.FileDescriptor

Functions

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 AddImageReq

type AddImageReq struct {
	Images []*Image `protobuf:"bytes,1,rep,name=images,proto3" json:"images,omitempty"`
	// contains filtered or unexported fields
}

func (*AddImageReq) Descriptor deprecated

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

Deprecated: Use AddImageReq.ProtoReflect.Descriptor instead.

func (*AddImageReq) GetImages

func (x *AddImageReq) GetImages() []*Image

func (*AddImageReq) ProtoMessage

func (*AddImageReq) ProtoMessage()

func (*AddImageReq) ProtoReflect

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

func (*AddImageReq) Reset

func (x *AddImageReq) Reset()

func (*AddImageReq) String

func (x *AddImageReq) String() string

type AddImageResp

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

func (*AddImageResp) Descriptor deprecated

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

Deprecated: Use AddImageResp.ProtoReflect.Descriptor instead.

func (*AddImageResp) ProtoMessage

func (*AddImageResp) ProtoMessage()

func (*AddImageResp) ProtoReflect

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

func (*AddImageResp) Reset

func (x *AddImageResp) Reset()

func (*AddImageResp) String

func (x *AddImageResp) 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 Image

type Image struct {
	Width  uint32 `protobuf:"varint,1,opt,name=width,proto3" json:"width,omitempty"`
	Height uint32 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"`
	// Types that are assignable to Image:
	//
	//	*Image_Rgb8
	//	*Image_Rgba8
	//	*Image_Png
	//	*Image_Jpeg
	Image isImage_Image `protobuf_oneof:"image"`
	// contains filtered or unexported fields
}

func (*Image) Decode

func (p *Image) Decode() (image.Image, error)

func (*Image) Descriptor deprecated

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

Deprecated: Use Image.ProtoReflect.Descriptor instead.

func (*Image) GetHeight

func (x *Image) GetHeight() uint32

func (*Image) GetImage

func (m *Image) GetImage() isImage_Image

func (*Image) GetJpeg

func (x *Image) GetJpeg() []byte

func (*Image) GetPng

func (x *Image) GetPng() []byte

func (*Image) GetRgb8

func (x *Image) GetRgb8() []byte

func (*Image) GetRgba8

func (x *Image) GetRgba8() []byte

func (*Image) GetWidth

func (x *Image) GetWidth() uint32

func (*Image) ProtoMessage

func (*Image) ProtoMessage()

func (*Image) ProtoReflect

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

func (*Image) Reset

func (x *Image) Reset()

func (*Image) String

func (x *Image) String() string

type Image_Jpeg

type Image_Jpeg struct {
	Jpeg []byte `protobuf:"bytes,6,opt,name=jpeg,proto3,oneof"` // JPEG bytes
}

type Image_Png

type Image_Png struct {
	Png []byte `protobuf:"bytes,5,opt,name=png,proto3,oneof"` // PNG bytes
}

type Image_Rgb8

type Image_Rgb8 struct {
	Rgb8 []byte `protobuf:"bytes,3,opt,name=rgb8,proto3,oneof"` // 8 bit per channel RGB
}

type Image_Rgba8

type Image_Rgba8 struct {
	Rgba8 []byte `protobuf:"bytes,4,opt,name=rgba8,proto3,oneof"` // 8 bit per channel RGBA
}

type PhotoFrame

type PhotoFrame interface {
	SetGrid(context.Context, *SetGridReq) (*SetGridResp, error)

	AddImage(context.Context, *AddImageReq) (*AddImageResp, error)
}

func NewPhotoFrameJSONClient

func NewPhotoFrameJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) PhotoFrame

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

func NewPhotoFrameProtobufClient

func NewPhotoFrameProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) PhotoFrame

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

type SetGridReq

type SetGridReq struct {
	Cols        uint32                    `protobuf:"varint,1,opt,name=cols,proto3" json:"cols,omitempty"`
	Rows        uint32                    `protobuf:"varint,2,opt,name=rows,proto3" json:"rows,omitempty"`
	OldImageAct SetGridReq_OldImageAction ``                                                                  /* 137-byte string literal not displayed */
	Images      []*Image                  `protobuf:"bytes,4,rep,name=images,proto3" json:"images,omitempty"` // if set, should be exactly rows * cols
	// contains filtered or unexported fields
}

func (*SetGridReq) Descriptor deprecated

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

Deprecated: Use SetGridReq.ProtoReflect.Descriptor instead.

func (*SetGridReq) GetCols

func (x *SetGridReq) GetCols() uint32

func (*SetGridReq) GetImages

func (x *SetGridReq) GetImages() []*Image

func (*SetGridReq) GetOldImageAct

func (x *SetGridReq) GetOldImageAct() SetGridReq_OldImageAction

func (*SetGridReq) GetRows

func (x *SetGridReq) GetRows() uint32

func (*SetGridReq) ProtoMessage

func (*SetGridReq) ProtoMessage()

func (*SetGridReq) ProtoReflect

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

func (*SetGridReq) Reset

func (x *SetGridReq) Reset()

func (*SetGridReq) String

func (x *SetGridReq) String() string

type SetGridReq_OldImageAction

type SetGridReq_OldImageAction int32
const (
	SetGridReq_OLD_IMAGE_KEEP SetGridReq_OldImageAction = 0 // keep old images on a new grid
	SetGridReq_OLD_IMAGE_WIPE SetGridReq_OldImageAction = 1 // remove old images from the grid
	SetGridReq_OLD_IMAGE_FADE SetGridReq_OldImageAction = 2 // fade old images on a new grid
)

func (SetGridReq_OldImageAction) Descriptor

func (SetGridReq_OldImageAction) Enum

func (SetGridReq_OldImageAction) EnumDescriptor deprecated

func (SetGridReq_OldImageAction) EnumDescriptor() ([]byte, []int)

Deprecated: Use SetGridReq_OldImageAction.Descriptor instead.

func (SetGridReq_OldImageAction) Number

func (SetGridReq_OldImageAction) String

func (x SetGridReq_OldImageAction) String() string

func (SetGridReq_OldImageAction) Type

type SetGridResp

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

func (*SetGridResp) Descriptor deprecated

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

Deprecated: Use SetGridResp.ProtoReflect.Descriptor instead.

func (*SetGridResp) ProtoMessage

func (*SetGridResp) ProtoMessage()

func (*SetGridResp) ProtoReflect

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

func (*SetGridResp) Reset

func (x *SetGridResp) Reset()

func (*SetGridResp) String

func (x *SetGridResp) String() string

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 NewPhotoFrameServer

func NewPhotoFrameServer(svc PhotoFrame, opts ...interface{}) TwirpServer

NewPhotoFrameServer 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