serverutils

package
v0.13.4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 12 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 ReadMessage added in v0.13.4

func ReadMessage(ctx context.Context, msg protoreflect.ProtoMessage, r *bufio.Reader) error

ReadMessage reads protocol buffers from the given bufio.Reader.

func Serve

func Serve(probeFunc func(*serverpb.ProbeRequest, *serverpb.ProbeReply))

Serve is similar to ServeContext but uses the background context.

func ServeContext added in v0.13.4

func ServeContext(probeFunc func(*serverpb.ProbeRequest, *serverpb.ProbeReply))

ServeContext 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.ServeContext(ctx, 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