api

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ClientServicePathPrefix = "/twirp/api.ClientService/"

ClientServicePathPrefix 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 (
	Log_Level_name = map[int32]string{
		0: "DEBUG",
		1: "INFO",
		2: "WARN",
		3: "ERROR",
	}
	Log_Level_value = map[string]int32{
		"DEBUG": 0,
		"INFO":  1,
		"WARN":  2,
		"ERROR": 3,
	}
)

Enum value maps for Log_Level.

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 Attachment

type Attachment struct {
	Filename    string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"`
	ContentType string `protobuf:"bytes,2,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
	Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
	Version     string `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"`
	// Types that are assignable to Content:
	//
	//	*Attachment_Data
	//	*Attachment_Url
	Content isAttachment_Content `protobuf_oneof:"content"`
	// contains filtered or unexported fields
}

func (*Attachment) Descriptor deprecated

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

Deprecated: Use Attachment.ProtoReflect.Descriptor instead.

func (*Attachment) GetContent

func (m *Attachment) GetContent() isAttachment_Content

func (*Attachment) GetContentType

func (x *Attachment) GetContentType() string

func (*Attachment) GetData

func (x *Attachment) GetData() []byte

func (*Attachment) GetDescription

func (x *Attachment) GetDescription() string

func (*Attachment) GetFilename

func (x *Attachment) GetFilename() string

func (*Attachment) GetUrl

func (x *Attachment) GetUrl() string

func (*Attachment) GetVersion

func (x *Attachment) GetVersion() string

func (*Attachment) ProtoMessage

func (*Attachment) ProtoMessage()

func (*Attachment) ProtoReflect added in v1.6.0

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

func (*Attachment) Reset

func (x *Attachment) Reset()

func (*Attachment) String

func (x *Attachment) String() string

type Attachment_Data

type Attachment_Data struct {
	Data []byte `protobuf:"bytes,5,opt,name=data,proto3,oneof"`
}

type Attachment_Url

type Attachment_Url struct {
	Url string `protobuf:"bytes,6,opt,name=url,proto3,oneof"`
}

type ClientService

type ClientService interface {
	ListConfigs(context.Context, *Empty) (*Configuration, error)

	AddAttachment(context.Context, *Attachment) (*Confirm, error)

	AddMessage(context.Context, *Message) (*Confirm, error)

	ListMessages(context.Context, *Empty) (*Messages, error)

	ConfirmMessage(context.Context, *Confirm) (*Empty, error)

	AddHealth(context.Context, *HealthInfo) (*Empty, error)
}

func NewClientServiceJSONClient

func NewClientServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) ClientService

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

func NewClientServiceProtobufClient

func NewClientServiceProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) ClientService

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

type Configuration

type Configuration struct {
	Inbound  []*ProcessConfig `protobuf:"bytes,1,rep,name=inbound,proto3" json:"inbound,omitempty"`
	Outbound []*ProcessConfig `protobuf:"bytes,2,rep,name=outbound,proto3" json:"outbound,omitempty"`
	// contains filtered or unexported fields
}

func (*Configuration) Descriptor deprecated

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

Deprecated: Use Configuration.ProtoReflect.Descriptor instead.

func (*Configuration) GetInbound

func (x *Configuration) GetInbound() []*ProcessConfig

func (*Configuration) GetOutbound

func (x *Configuration) GetOutbound() []*ProcessConfig

func (*Configuration) ProtoMessage

func (*Configuration) ProtoMessage()

func (*Configuration) ProtoReflect added in v1.6.0

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

func (*Configuration) Reset

func (x *Configuration) Reset()

func (*Configuration) String

func (x *Configuration) String() string

type Confirm

type Confirm struct {
	ProcessId  string `protobuf:"bytes,1,opt,name=process_id,json=processId,proto3" json:"process_id,omitempty"`     // process id oth the message to confirm
	Id         string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`                                    // identifier of the message for example the database id
	Success    bool   `protobuf:"varint,3,opt,name=success,proto3" json:"success,omitempty"`                         // receive success
	Logs       []*Log `protobuf:"bytes,4,rep,name=logs,proto3" json:"logs,omitempty"`                                // log informations
	StatusCode int32  `protobuf:"varint,5,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // statuscode
	// contains filtered or unexported fields
}

Confirmation of a message

func (*Confirm) Descriptor deprecated

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

Deprecated: Use Confirm.ProtoReflect.Descriptor instead.

func (*Confirm) GetId

func (x *Confirm) GetId() string

func (*Confirm) GetLogs

func (x *Confirm) GetLogs() []*Log

func (*Confirm) GetProcessId

func (x *Confirm) GetProcessId() string

func (*Confirm) GetStatusCode

func (x *Confirm) GetStatusCode() int32

func (*Confirm) GetSuccess

func (x *Confirm) GetSuccess() bool

func (*Confirm) ProtoMessage

func (*Confirm) ProtoMessage()

func (*Confirm) ProtoReflect added in v1.6.0

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

func (*Confirm) Reset

func (x *Confirm) Reset()

func (*Confirm) String

func (x *Confirm) String() string

type Empty

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

func (*Empty) Descriptor deprecated

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

Deprecated: Use Empty.ProtoReflect.Descriptor instead.

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) ProtoReflect added in v1.6.0

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

func (*Empty) Reset

func (x *Empty) Reset()

func (*Empty) String

func (x *Empty) 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 HealthInfo

type HealthInfo struct {
	Cpu     float64 `protobuf:"fixed64,1,opt,name=cpu,proto3" json:"cpu,omitempty"`
	Ram     float64 `protobuf:"fixed64,2,opt,name=ram,proto3" json:"ram,omitempty"`
	Status  string  `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"`
	Threads uint32  `protobuf:"varint,4,opt,name=threads,proto3" json:"threads,omitempty"`
	Uptime  uint64  `protobuf:"varint,5,opt,name=uptime,proto3" json:"uptime,omitempty"`
	Os      string  `protobuf:"bytes,6,opt,name=os,proto3" json:"os,omitempty"`
	// contains filtered or unexported fields
}

func (*HealthInfo) Descriptor deprecated

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

Deprecated: Use HealthInfo.ProtoReflect.Descriptor instead.

func (*HealthInfo) GetCpu

func (x *HealthInfo) GetCpu() float64

func (*HealthInfo) GetOs

func (x *HealthInfo) GetOs() string

func (*HealthInfo) GetRam

func (x *HealthInfo) GetRam() float64

func (*HealthInfo) GetStatus

func (x *HealthInfo) GetStatus() string

func (*HealthInfo) GetThreads

func (x *HealthInfo) GetThreads() uint32

func (*HealthInfo) GetUptime

func (x *HealthInfo) GetUptime() uint64

func (*HealthInfo) ProtoMessage

func (*HealthInfo) ProtoMessage()

func (*HealthInfo) ProtoReflect added in v1.6.0

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

func (*HealthInfo) Reset

func (x *HealthInfo) Reset()

func (*HealthInfo) String

func (x *HealthInfo) String() string

type Log

type Log struct {
	Level       Log_Level `protobuf:"varint,1,opt,name=level,proto3,enum=api.Log_Level" json:"level,omitempty"`
	Description string    `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// contains filtered or unexported fields
}

func (*Log) Descriptor deprecated

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

Deprecated: Use Log.ProtoReflect.Descriptor instead.

func (*Log) GetDescription

func (x *Log) GetDescription() string

func (*Log) GetLevel

func (x *Log) GetLevel() Log_Level

func (*Log) ProtoMessage

func (*Log) ProtoMessage()

func (*Log) ProtoReflect added in v1.6.0

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

func (*Log) Reset

func (x *Log) Reset()

func (*Log) String

func (x *Log) String() string

type Log_Level

type Log_Level int32
const (
	Log_DEBUG Log_Level = 0
	Log_INFO  Log_Level = 1
	Log_WARN  Log_Level = 2
	Log_ERROR Log_Level = 3
)

func (Log_Level) Descriptor added in v1.6.0

func (Log_Level) Descriptor() protoreflect.EnumDescriptor

func (Log_Level) Enum added in v1.6.0

func (x Log_Level) Enum() *Log_Level

func (Log_Level) EnumDescriptor deprecated

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

Deprecated: Use Log_Level.Descriptor instead.

func (Log_Level) Number added in v1.6.0

func (x Log_Level) Number() protoreflect.EnumNumber

func (Log_Level) String

func (x Log_Level) String() string

func (Log_Level) Type added in v1.6.0

type Message

type Message struct {
	ProcessId  string            `protobuf:"bytes,1,opt,name=process_id,json=processId,proto3" json:"process_id,omitempty"` // processid for reference to convert in the cloud
	Id         string            `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`                                // identifier of the message for example the database id
	Test       bool              `protobuf:"varint,3,opt,name=test,proto3" json:"test,omitempty"`                           // is this message a test message?
	Properties map[string]string ``                                                                                         // Extra information for example the filename
	/* 161-byte string literal not displayed */
	Content     []byte        `protobuf:"bytes,5,opt,name=content,proto3" json:"content,omitempty"`         // the message itself
	Attachments []*Attachment `protobuf:"bytes,6,rep,name=attachments,proto3" json:"attachments,omitempty"` // list of attchments to this message
	// contains filtered or unexported fields
}

Message is a edi message with extra information

func (*Message) Descriptor deprecated

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

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) GetAttachments

func (x *Message) GetAttachments() []*Attachment

func (*Message) GetContent

func (x *Message) GetContent() []byte

func (*Message) GetId

func (x *Message) GetId() string

func (*Message) GetProcessId

func (x *Message) GetProcessId() string

func (*Message) GetProperties

func (x *Message) GetProperties() map[string]string

func (*Message) GetTest

func (x *Message) GetTest() bool

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) ProtoReflect added in v1.6.0

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

func (*Message) Reset

func (x *Message) Reset()

func (*Message) String

func (x *Message) String() string

type Messages

type Messages struct {
	Messages []*Message `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"`
	// contains filtered or unexported fields
}

List of Messages

func (*Messages) Descriptor deprecated

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

Deprecated: Use Messages.ProtoReflect.Descriptor instead.

func (*Messages) GetMessages

func (x *Messages) GetMessages() []*Message

func (*Messages) ProtoMessage

func (*Messages) ProtoMessage()

func (*Messages) ProtoReflect added in v1.6.0

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

func (*Messages) Reset

func (x *Messages) Reset()

func (*Messages) String

func (x *Messages) String() string

type ProcessConfig

type ProcessConfig struct {
	ProcessId string            `protobuf:"bytes,1,opt,name=process_id,json=processId,proto3" json:"process_id,omitempty"`
	Type      string            `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
	Parameter map[string]string `` /* 159-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*ProcessConfig) Descriptor deprecated

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

Deprecated: Use ProcessConfig.ProtoReflect.Descriptor instead.

func (*ProcessConfig) GetParameter

func (x *ProcessConfig) GetParameter() map[string]string

func (*ProcessConfig) GetProcessId

func (x *ProcessConfig) GetProcessId() string

func (*ProcessConfig) GetType

func (x *ProcessConfig) GetType() string

func (*ProcessConfig) ProtoMessage

func (*ProcessConfig) ProtoMessage()

func (*ProcessConfig) ProtoReflect added in v1.6.0

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

func (*ProcessConfig) Reset

func (x *ProcessConfig) Reset()

func (*ProcessConfig) String

func (x *ProcessConfig) 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 NewClientServiceServer

func NewClientServiceServer(svc ClientService, opts ...interface{}) TwirpServer

NewClientServiceServer 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