serverutils

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

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/cloudprober/cloudprober/probes/external/proto"
		"github.com/cloudprober/cloudprober/probes/external/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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL