Documentation ¶
Overview ¶
Package serverutils is a generated protocol buffer package.
It is generated from these files:
github.com/google/cloudprober/probes/external/serverutils/server.proto
It has these top-level messages:
ProbeRequest ProbeReply
Package serverutils provides utilities to work with the cloudprober's external probe.
Index ¶
- func Serve(probeFunc func(*ProbeRequest, *ProbeReply))
- func WriteMessage(pb proto.Message, w io.Writer) error
- type ProbeReply
- type ProbeRequest
- func (*ProbeRequest) Descriptor() ([]byte, []int)
- func (m *ProbeRequest) GetOptions() []*ProbeRequest_Option
- func (m *ProbeRequest) GetRequestId() int32
- func (m *ProbeRequest) GetTimeLimit() int32
- func (*ProbeRequest) ProtoMessage()
- func (m *ProbeRequest) Reset()
- func (m *ProbeRequest) String() string
- type ProbeRequest_Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Serve ¶
func Serve(probeFunc func(*ProbeRequest, *ProbeReply))
Serve blocks indefinitely, servicing probe requests. Note that this function is provided mainly to help external probe server implementations. Cloudprober doesn't make use of it. Example usage:
import ( serverpb "github.com/google/cloudprober/probes/external/serverutils/server_proto" "github.com/google/cloudprober/probes/external/serverutils/serverutils" ) func runProbe(opts []*cppb.ProbeRequest_Option) { ... } serverutils.Serve(func(req *ProbeRequest, reply *ProbeReply) { payload, errMsg, _ := runProbe(req.GetOptions()) reply.Payload = proto.String(payload) if errMsg != "" { reply.ErrorMessage = proto.String(errMsg) } })
Types ¶
type ProbeReply ¶
type ProbeReply struct { // The sequence number for this request. RequestId *int32 `protobuf:"varint,1,req,name=request_id,json=requestId" json:"request_id,omitempty"` // For a normal result, this is not present. // If it is present, it indicates that the probe failed. ErrorMessage *string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage" json:"error_message,omitempty"` // The result of the probe. Cloudprober parses the payload to retrieve // variables from it. It expects variables in the following format: // var1 value1 (for example: total_errors 589) // TODO: Add an option to export mapped variables, for example: // client-errors map:lang java:200 python:20 golang:3 Payload *string `protobuf:"bytes,3,opt,name=payload" json:"payload,omitempty"` XXX_unrecognized []byte `json:"-"` }
ProbeReply is the message that external probe server sends back to the cloudprober.
func ReadProbeReply ¶
func ReadProbeReply(r *bufio.Reader) (*ProbeReply, error)
ReadProbeReply reads ProbeReply from the supplied bufio.Reader and returns it to the caller.
func (*ProbeReply) Descriptor ¶
func (*ProbeReply) Descriptor() ([]byte, []int)
func (*ProbeReply) GetErrorMessage ¶
func (m *ProbeReply) GetErrorMessage() string
func (*ProbeReply) GetPayload ¶
func (m *ProbeReply) GetPayload() string
func (*ProbeReply) GetRequestId ¶
func (m *ProbeReply) GetRequestId() int32
func (*ProbeReply) ProtoMessage ¶
func (*ProbeReply) ProtoMessage()
func (*ProbeReply) Reset ¶
func (m *ProbeReply) Reset()
func (*ProbeReply) String ¶
func (m *ProbeReply) String() string
type ProbeRequest ¶
type ProbeRequest struct { // The unique identifier for this request. This is unique across // an execution of the probe server. It starts at 1. RequestId *int32 `protobuf:"varint,1,req,name=request_id,json=requestId" json:"request_id,omitempty"` // How long to allow for the execution of this request, in // milliseconds. If the time limit is exceeded, the server // should abort the request, but *not* send back a reply. The // client will have to do timeouts anyway. TimeLimit *int32 `protobuf:"varint,2,req,name=time_limit,json=timeLimit" json:"time_limit,omitempty"` Options []*ProbeRequest_Option `protobuf:"bytes,3,rep,name=options" json:"options,omitempty"` XXX_unrecognized []byte `json:"-"` }
ProbeRequest is the message that cloudprober sends to the external probe server.
func ReadProbeRequest ¶
func ReadProbeRequest(r *bufio.Reader) (*ProbeRequest, error)
ReadProbeRequest reads and parses ProbeRequest protocol buffers from the given bufio.Reader.
func (*ProbeRequest) Descriptor ¶
func (*ProbeRequest) Descriptor() ([]byte, []int)
func (*ProbeRequest) GetOptions ¶
func (m *ProbeRequest) GetOptions() []*ProbeRequest_Option
func (*ProbeRequest) GetRequestId ¶
func (m *ProbeRequest) GetRequestId() int32
func (*ProbeRequest) GetTimeLimit ¶
func (m *ProbeRequest) GetTimeLimit() int32
func (*ProbeRequest) ProtoMessage ¶
func (*ProbeRequest) ProtoMessage()
func (*ProbeRequest) Reset ¶
func (m *ProbeRequest) Reset()
func (*ProbeRequest) String ¶
func (m *ProbeRequest) String() string
type ProbeRequest_Option ¶
type ProbeRequest_Option struct { Name *string `protobuf:"bytes,1,req,name=name" json:"name,omitempty"` Value *string `protobuf:"bytes,2,req,name=value" json:"value,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*ProbeRequest_Option) Descriptor ¶
func (*ProbeRequest_Option) Descriptor() ([]byte, []int)
func (*ProbeRequest_Option) GetName ¶
func (m *ProbeRequest_Option) GetName() string
func (*ProbeRequest_Option) GetValue ¶
func (m *ProbeRequest_Option) GetValue() string
func (*ProbeRequest_Option) ProtoMessage ¶
func (*ProbeRequest_Option) ProtoMessage()
func (*ProbeRequest_Option) Reset ¶
func (m *ProbeRequest_Option) Reset()
func (*ProbeRequest_Option) String ¶
func (m *ProbeRequest_Option) String() string