rpc

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const PoeStatusPathPrefix = "/twirp/rpc.PoeStatus/"

PoeStatusPathPrefix 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_service_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 AuthToken

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

func (*AuthToken) Descriptor deprecated

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

Deprecated: Use AuthToken.ProtoReflect.Descriptor instead.

func (*AuthToken) GetToken

func (x *AuthToken) GetToken() string

func (*AuthToken) ProtoMessage

func (*AuthToken) ProtoMessage()

func (*AuthToken) ProtoReflect

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

func (*AuthToken) Reset

func (x *AuthToken) Reset()

func (*AuthToken) String

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

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 PingInfo

type PingInfo struct {
	Transmitted int32  `protobuf:"varint,1,opt,name=Transmitted,proto3" json:"Transmitted,omitempty"`
	Received    int32  `protobuf:"varint,2,opt,name=Received,proto3" json:"Received,omitempty"`
	Loss        int32  `protobuf:"varint,3,opt,name=Loss,proto3" json:"Loss,omitempty"`
	Output      string `protobuf:"bytes,4,opt,name=Output,proto3" json:"Output,omitempty"`
	// contains filtered or unexported fields
}

func (*PingInfo) Descriptor deprecated

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

Deprecated: Use PingInfo.ProtoReflect.Descriptor instead.

func (*PingInfo) GetLoss

func (x *PingInfo) GetLoss() int32

func (*PingInfo) GetOutput

func (x *PingInfo) GetOutput() string

func (*PingInfo) GetReceived

func (x *PingInfo) GetReceived() int32

func (*PingInfo) GetTransmitted

func (x *PingInfo) GetTransmitted() int32

func (*PingInfo) ProtoMessage

func (*PingInfo) ProtoMessage()

func (*PingInfo) ProtoReflect

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

func (*PingInfo) Reset

func (x *PingInfo) Reset()

func (*PingInfo) String

func (x *PingInfo) String() string

type PoeStatus

type PoeStatus interface {
	SaveScanResults(context.Context, *ScanResults) (*Empty, error)
}

func NewPoeStatusJSONClient

func NewPoeStatusJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) PoeStatus

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

func NewPoeStatusProtobufClient

func NewPoeStatusProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) PoeStatus

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

type PortInfo

type PortInfo struct {
	Port int32 `protobuf:"varint,1,opt,name=Port,proto3" json:"Port,omitempty"`
	Open bool  `protobuf:"varint,2,opt,name=Open,proto3" json:"Open,omitempty"`
	// contains filtered or unexported fields
}

func (*PortInfo) Descriptor deprecated

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

Deprecated: Use PortInfo.ProtoReflect.Descriptor instead.

func (*PortInfo) GetOpen

func (x *PortInfo) GetOpen() bool

func (*PortInfo) GetPort

func (x *PortInfo) GetPort() int32

func (*PortInfo) ProtoMessage

func (*PortInfo) ProtoMessage()

func (*PortInfo) ProtoReflect

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

func (*PortInfo) Reset

func (x *PortInfo) Reset()

func (*PortInfo) String

func (x *PortInfo) String() string

type ScanResults

type ScanResults struct {
	ScanIP    string               `protobuf:"bytes,1,opt,name=ScanIP,proto3" json:"ScanIP,omitempty"`
	Host      string               `protobuf:"bytes,2,opt,name=Host,proto3" json:"Host,omitempty"`
	CreatedAt *timestamp.Timestamp `protobuf:"bytes,3,opt,name=CreatedAt,proto3" json:"CreatedAt,omitempty"`
	Ports     []*PortInfo          `protobuf:"bytes,4,rep,name=Ports,proto3" json:"Ports,omitempty"`
	ScanError string               `protobuf:"bytes,5,opt,name=ScanError,proto3" json:"ScanError,omitempty"`
	Platform  string               `protobuf:"bytes,6,opt,name=Platform,proto3" json:"Platform,omitempty"`
	PingInfo  *PingInfo            `protobuf:"bytes,7,opt,name=PingInfo,proto3" json:"PingInfo,omitempty"`
	AuthToken *AuthToken           `protobuf:"bytes,8,opt,name=AuthToken,proto3" json:"AuthToken,omitempty"`
	// contains filtered or unexported fields
}

func (*ScanResults) Descriptor deprecated

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

Deprecated: Use ScanResults.ProtoReflect.Descriptor instead.

func (*ScanResults) GetAuthToken

func (x *ScanResults) GetAuthToken() *AuthToken

func (*ScanResults) GetCreatedAt

func (x *ScanResults) GetCreatedAt() *timestamp.Timestamp

func (*ScanResults) GetHost

func (x *ScanResults) GetHost() string

func (*ScanResults) GetPingInfo

func (x *ScanResults) GetPingInfo() *PingInfo

func (*ScanResults) GetPlatform

func (x *ScanResults) GetPlatform() string

func (*ScanResults) GetPorts

func (x *ScanResults) GetPorts() []*PortInfo

func (*ScanResults) GetScanError

func (x *ScanResults) GetScanError() string

func (*ScanResults) GetScanIP

func (x *ScanResults) GetScanIP() string

func (*ScanResults) ProtoMessage

func (*ScanResults) ProtoMessage()

func (*ScanResults) ProtoReflect

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

func (*ScanResults) Reset

func (x *ScanResults) Reset()

func (*ScanResults) String

func (x *ScanResults) 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 NewPoeStatusServer

func NewPoeStatusServer(svc PoeStatus, opts ...interface{}) TwirpServer

NewPoeStatusServer 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