Documentation

Overview

    Package serverutils provides utilities to work with the cloudprober's external probe.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func ReadProbeReply

    func ReadProbeReply(r *bufio.Reader) (*serverpb.ProbeReply, error)

      ReadProbeReply reads ProbeReply from the supplied bufio.Reader and returns it to the caller.

      func ReadProbeRequest

      func ReadProbeRequest(r *bufio.Reader) (*serverpb.ProbeRequest, error)

        ReadProbeRequest reads and parses ProbeRequest protocol buffers from the given bufio.Reader.

        func Serve

        func Serve(probeFunc func(*serverpb.ProbeRequest, *serverpb.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 *serverpb.ProbeRequest, reply *serverpb.ProbeReply) {
          		payload, errMsg, _ := runProbe(req.GetOptions())
          		reply.Payload = proto.String(payload)
          		if errMsg != "" {
          			reply.ErrorMessage = proto.String(errMsg)
          		}
          	})
          

          func WriteMessage

          func WriteMessage(pb proto.Message, w io.Writer) error

            WriteMessage marshals the a proto message and writes it to the writer "w" with appropriate Content-Length header.

            Types

            This section is empty.

            Source Files