pb

package
v0.0.0-...-29c3169 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const MonitorPathPrefix = "/twirp/api.Monitor/"

MonitorPathPrefix 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_monitor_manager_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 Config

type Config struct {
	Samples    int32       `protobuf:"varint,1,opt,name=Samples,proto3" json:"Samples,omitempty"`
	IPBytes    []byte      `protobuf:"bytes,2,opt,name=IPBytes,proto3" json:"IPBytes,omitempty"`
	IPNatBytes []byte      `protobuf:"bytes,3,opt,name=IPNatBytes,proto3" json:"IPNatBytes,omitempty"`
	BaseChecks [][]byte    `protobuf:"bytes,4,rep,name=BaseChecks,proto3" json:"BaseChecks,omitempty"`
	MQTTConfig *MQTTConfig `protobuf:"bytes,5,opt,name=MQTTConfig,proto3" json:"MQTTConfig,omitempty"`
	// contains filtered or unexported fields
}

Config is the server set configuration for the monitoring agent

func (*Config) Descriptor deprecated

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

Deprecated: Use Config.ProtoReflect.Descriptor instead.

func (*Config) GetBaseChecks

func (x *Config) GetBaseChecks() [][]byte

func (*Config) GetIP

func (cfg *Config) GetIP() *netip.Addr

func (*Config) GetIPBytes

func (x *Config) GetIPBytes() []byte

func (*Config) GetIPNatBytes

func (x *Config) GetIPNatBytes() []byte

func (*Config) GetMQTTConfig

func (x *Config) GetMQTTConfig() *MQTTConfig

func (*Config) GetNatIP

func (cfg *Config) GetNatIP() *netip.Addr

func (*Config) GetSamples

func (x *Config) GetSamples() int32

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) ProtoReflect

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

func (*Config) Reset

func (x *Config) Reset()

func (*Config) String

func (x *Config) String() string

type GetConfigParams

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

func (*GetConfigParams) Descriptor deprecated

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

Deprecated: Use GetConfigParams.ProtoReflect.Descriptor instead.

func (*GetConfigParams) ProtoMessage

func (*GetConfigParams) ProtoMessage()

func (*GetConfigParams) ProtoReflect

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

func (*GetConfigParams) Reset

func (x *GetConfigParams) Reset()

func (*GetConfigParams) String

func (x *GetConfigParams) String() string

type GetServersParams

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

func (*GetServersParams) Descriptor deprecated

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

Deprecated: Use GetServersParams.ProtoReflect.Descriptor instead.

func (*GetServersParams) ProtoMessage

func (*GetServersParams) ProtoMessage()

func (*GetServersParams) ProtoReflect

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

func (*GetServersParams) Reset

func (x *GetServersParams) Reset()

func (*GetServersParams) String

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

type MQTTConfig struct {
	Host   []byte `protobuf:"bytes,1,opt,name=Host,proto3" json:"Host,omitempty"`
	Port   int32  `protobuf:"varint,2,opt,name=Port,proto3" json:"Port,omitempty"`
	JWT    []byte `protobuf:"bytes,3,opt,name=JWT,proto3" json:"JWT,omitempty"`
	Prefix []byte `protobuf:"bytes,4,opt,name=Prefix,proto3" json:"Prefix,omitempty"` // base prefix for topic ("/devel/monitors/" for example)
	// contains filtered or unexported fields
}

func (*MQTTConfig) Descriptor deprecated

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

Deprecated: Use MQTTConfig.ProtoReflect.Descriptor instead.

func (*MQTTConfig) GetHost

func (x *MQTTConfig) GetHost() []byte

func (*MQTTConfig) GetJWT

func (x *MQTTConfig) GetJWT() []byte

func (*MQTTConfig) GetPort

func (x *MQTTConfig) GetPort() int32

func (*MQTTConfig) GetPrefix

func (x *MQTTConfig) GetPrefix() []byte

func (*MQTTConfig) ProtoMessage

func (*MQTTConfig) ProtoMessage()

func (*MQTTConfig) ProtoReflect

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

func (*MQTTConfig) Reset

func (x *MQTTConfig) Reset()

func (*MQTTConfig) String

func (x *MQTTConfig) String() string

type Monitor

type Monitor interface {
	GetConfig(context.Context, *GetConfigParams) (*Config, error)

	// GetServers fetches list of NTP servers to check
	GetServers(context.Context, *GetServersParams) (*ServerList, error)

	// SubmitResults returns the specified list ServerStatus to the monitoring server
	SubmitResults(context.Context, *ServerStatusList) (*ServerStatusResult, error)
}

func NewMonitorJSONClient

func NewMonitorJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Monitor

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

func NewMonitorProtobufClient

func NewMonitorProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Monitor

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

type Server

type Server struct {
	IPBytes []byte `protobuf:"bytes,1,opt,name=IPBytes,proto3" json:"IPBytes,omitempty"`
	Ticket  []byte `protobuf:"bytes,2,opt,name=Ticket,proto3" json:"Ticket,omitempty"`
	Trace   bool   `protobuf:"varint,3,opt,name=Trace,proto3" json:"Trace,omitempty"`
	// contains filtered or unexported fields
}

func (*Server) Descriptor deprecated

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

Deprecated: Use Server.ProtoReflect.Descriptor instead.

func (*Server) GetIPBytes

func (x *Server) GetIPBytes() []byte

func (*Server) GetTicket

func (x *Server) GetTicket() []byte

func (*Server) GetTrace

func (x *Server) GetTrace() bool

func (*Server) IP

func (s *Server) IP() *netip.Addr

func (*Server) ProtoMessage

func (*Server) ProtoMessage()

func (*Server) ProtoReflect

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

func (*Server) Reset

func (x *Server) Reset()

func (*Server) String

func (x *Server) String() string

type ServerList

type ServerList struct {
	Config  *Config   `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"`
	Servers []*Server `protobuf:"bytes,2,rep,name=Servers,proto3" json:"Servers,omitempty"`
	BatchID []byte    `protobuf:"bytes,3,opt,name=BatchID,proto3" json:"BatchID,omitempty"` // todo future api: move this first
	// contains filtered or unexported fields
}

func (*ServerList) Descriptor deprecated

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

Deprecated: Use ServerList.ProtoReflect.Descriptor instead.

func (*ServerList) GetBatchID

func (x *ServerList) GetBatchID() []byte

func (*ServerList) GetConfig

func (x *ServerList) GetConfig() *Config

func (*ServerList) GetServers

func (x *ServerList) GetServers() []*Server

func (*ServerList) ProtoMessage

func (*ServerList) ProtoMessage()

func (*ServerList) ProtoReflect

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

func (*ServerList) Reset

func (x *ServerList) Reset()

func (*ServerList) String

func (x *ServerList) String() string

type ServerStatus

type ServerStatus struct {
	Ticket     []byte                 `protobuf:"bytes,1,opt,name=Ticket,proto3" json:"Ticket,omitempty"`
	IPBytes    []byte                 `protobuf:"bytes,2,opt,name=IPBytes,proto3" json:"IPBytes,omitempty"`
	TS         *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=TS,proto3" json:"TS,omitempty"`
	Offset     *durationpb.Duration   `protobuf:"bytes,4,opt,name=Offset,proto3" json:"Offset,omitempty"`
	RTT        *durationpb.Duration   `protobuf:"bytes,5,opt,name=RTT,proto3" json:"RTT,omitempty"`
	Stratum    int32                  `protobuf:"varint,6,opt,name=Stratum,proto3" json:"Stratum,omitempty"`
	Leap       int32                  `protobuf:"zigzag32,7,opt,name=Leap,proto3" json:"Leap,omitempty"`
	Error      string                 `protobuf:"bytes,8,opt,name=Error,proto3" json:"Error,omitempty"`
	NoResponse bool                   `protobuf:"varint,9,opt,name=NoResponse,proto3" json:"NoResponse,omitempty"`
	// contains filtered or unexported fields
}

func (*ServerStatus) AbsoluteOffset

func (ss *ServerStatus) AbsoluteOffset() *time.Duration

func (*ServerStatus) Descriptor deprecated

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

Deprecated: Use ServerStatus.ProtoReflect.Descriptor instead.

func (*ServerStatus) GetError

func (x *ServerStatus) GetError() string

func (*ServerStatus) GetIP

func (ss *ServerStatus) GetIP() *netip.Addr

func (*ServerStatus) GetIPBytes

func (x *ServerStatus) GetIPBytes() []byte

func (*ServerStatus) GetLeap

func (x *ServerStatus) GetLeap() int32

func (*ServerStatus) GetNoResponse

func (x *ServerStatus) GetNoResponse() bool

func (*ServerStatus) GetOffset

func (x *ServerStatus) GetOffset() *durationpb.Duration

func (*ServerStatus) GetRTT

func (x *ServerStatus) GetRTT() *durationpb.Duration

func (*ServerStatus) GetStratum

func (x *ServerStatus) GetStratum() int32

func (*ServerStatus) GetTS

func (x *ServerStatus) GetTS() *timestamppb.Timestamp

func (*ServerStatus) GetTicket

func (x *ServerStatus) GetTicket() []byte

func (*ServerStatus) ProtoMessage

func (*ServerStatus) ProtoMessage()

func (*ServerStatus) ProtoReflect

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

func (*ServerStatus) Reset

func (x *ServerStatus) Reset()

func (*ServerStatus) SetIP

func (ss *ServerStatus) SetIP(ip *netip.Addr)

func (*ServerStatus) String

func (x *ServerStatus) String() string

type ServerStatusList

type ServerStatusList struct {
	Version int32           `protobuf:"varint,1,opt,name=Version,proto3" json:"Version,omitempty"`
	List    []*ServerStatus `protobuf:"bytes,2,rep,name=List,proto3" json:"List,omitempty"`
	BatchID []byte          `protobuf:"bytes,3,opt,name=BatchID,proto3" json:"BatchID,omitempty"`
	// contains filtered or unexported fields
}

func (*ServerStatusList) Descriptor deprecated

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

Deprecated: Use ServerStatusList.ProtoReflect.Descriptor instead.

func (*ServerStatusList) GetBatchID

func (x *ServerStatusList) GetBatchID() []byte

func (*ServerStatusList) GetList

func (x *ServerStatusList) GetList() []*ServerStatus

func (*ServerStatusList) GetVersion

func (x *ServerStatusList) GetVersion() int32

func (*ServerStatusList) ProtoMessage

func (*ServerStatusList) ProtoMessage()

func (*ServerStatusList) ProtoReflect

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

func (*ServerStatusList) Reset

func (x *ServerStatusList) Reset()

func (*ServerStatusList) String

func (x *ServerStatusList) String() string

type ServerStatusResult

type ServerStatusResult struct {
	Ok bool `protobuf:"varint,1,opt,name=Ok,proto3" json:"Ok,omitempty"`
	// contains filtered or unexported fields
}

func (*ServerStatusResult) Descriptor deprecated

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

Deprecated: Use ServerStatusResult.ProtoReflect.Descriptor instead.

func (*ServerStatusResult) GetOk

func (x *ServerStatusResult) GetOk() bool

func (*ServerStatusResult) ProtoMessage

func (*ServerStatusResult) ProtoMessage()

func (*ServerStatusResult) ProtoReflect

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

func (*ServerStatusResult) Reset

func (x *ServerStatusResult) Reset()

func (*ServerStatusResult) String

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

func NewMonitorServer(svc Monitor, opts ...interface{}) TwirpServer

NewMonitorServer 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