calls

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Example
var (
	check = func(err error) {
		if err != nil {
			panic(err)
		}
	}
	swallow = func(_ mesos.Response, err error) { check(err) }

	ctx       = context.Background()
	sender    = SenderFunc(func(_ context.Context, _ Request) (_ mesos.Response, _ error) { return })
	blackhole = func(calls ...*agent.Call) {
		for i := range calls {
			swallow(sender.Send(ctx, NonStreaming(calls[i])))
		}
	}

	d = time.Duration(0)
)
blackhole(
	GetHealth(),
	GetFlags(),
	GetVersion(),
	GetMetrics(nil),
	GetMetrics(&d),
	GetLoggingLevel(),
	ListFiles(""),
	ReadFile("", 0),
	ReadFileWithLength("", 0, 0),
	GetState(),
	GetContainers(),
	GetFrameworks(),
	GetExecutors(),
	GetOperations(),
	GetTasks(),
	GetAgent(),
	GetResourceProviders(),
	WaitContainer(mesos.ContainerID{}),
	WaitNestedContainer(mesos.ContainerID{}),
	LaunchNestedContainerSession(mesos.ContainerID{}, nil, nil),
)

blackhole = func(calls ...*agent.Call) {
	for i := range calls {
		check(SendNoData(ctx, sender, NonStreaming(calls[i])))
	}
}
blackhole(
	SetLoggingLevel(0, d),
	LaunchContainer(mesos.ContainerID{}, nil, nil, nil),
	LaunchNestedContainer(mesos.ContainerID{}, nil, nil),
	KillContainer(mesos.ContainerID{}),
	KillNestedContainer(mesos.ContainerID{}),
	RemoveContainer(mesos.ContainerID{}),
	RemoveNestedContainer(mesos.ContainerID{}),
	AttachContainerOutput(mesos.ContainerID{}),
	AddResourceProviderConfig(mesos.ResourceProviderInfo{}),
	UpdateResourceProviderConfig(mesos.ResourceProviderInfo{}),
	RemoveResourceProviderConfig("", ""),
	PruneImages(nil),
)

swallow(sender.Send(ctx, Empty().Push(
	AttachContainerInput(mesos.ContainerID{}),
	AttachContainerInputTTY(nil),
	AttachContainerInputData(nil),
	AttachContainerInputHeartbeat(nil),
)))
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddResourceProviderConfig

func AddResourceProviderConfig(rpi mesos.ResourceProviderInfo) *agent.Call

func AttachContainerInput

func AttachContainerInput(cid mesos.ContainerID) *agent.Call

AttachContainerInput returns a Call that is used to initiate attachment to a container's stdin. Callers should first send this Call followed by one or more AttachContainerInputXxx calls.

func AttachContainerInputData

func AttachContainerInputData(data []byte) *agent.Call

func AttachContainerInputHeartbeat

func AttachContainerInputHeartbeat(heartbeat *agent.ProcessIO_Control_Heartbeat) *agent.Call

func AttachContainerInputTTY

func AttachContainerInputTTY(t *mesos.TTYInfo) *agent.Call

func AttachContainerOutput

func AttachContainerOutput(cid mesos.ContainerID) *agent.Call

func GetAgent

func GetAgent() *agent.Call

func GetContainers

func GetContainers() *agent.Call

func GetExecutors

func GetExecutors() *agent.Call

func GetFlags

func GetFlags() *agent.Call

func GetFrameworks

func GetFrameworks() *agent.Call

func GetHealth

func GetHealth() *agent.Call

func GetLoggingLevel

func GetLoggingLevel() *agent.Call

func GetMetrics

func GetMetrics(d *time.Duration) (call *agent.Call)

func GetOperations

func GetOperations() *agent.Call

func GetResourceProviders

func GetResourceProviders() *agent.Call

func GetState

func GetState() *agent.Call

func GetTasks

func GetTasks() *agent.Call

func GetVersion

func GetVersion() *agent.Call

func KillContainer

func KillContainer(cid mesos.ContainerID) *agent.Call

func KillNestedContainer

func KillNestedContainer(cid mesos.ContainerID) *agent.Call

func LaunchContainer

func LaunchContainer(cid mesos.ContainerID, cmd *mesos.CommandInfo, ci *mesos.ContainerInfo, r []mesos.Resource) *agent.Call

func LaunchNestedContainer

func LaunchNestedContainer(cid mesos.ContainerID, cmd *mesos.CommandInfo, ci *mesos.ContainerInfo) *agent.Call

func LaunchNestedContainerSession

func LaunchNestedContainerSession(cid mesos.ContainerID, cmd *mesos.CommandInfo, ci *mesos.ContainerInfo) *agent.Call

func ListFiles

func ListFiles(path string) *agent.Call

func MarkResourceProviderGone

func MarkResourceProviderGone(id mesos.ResourceProviderID) *agent.Call

func PruneImages

func PruneImages(excluded []mesos.Image) *agent.Call

func ReadFile

func ReadFile(path string, offset uint64) *agent.Call

func ReadFileWithLength

func ReadFileWithLength(path string, offset, length uint64) (call *agent.Call)

func RemoveContainer

func RemoveContainer(cid mesos.ContainerID) *agent.Call

func RemoveNestedContainer

func RemoveNestedContainer(cid mesos.ContainerID) *agent.Call

func RemoveResourceProviderConfig

func RemoveResourceProviderConfig(typ, name string) *agent.Call

func SendNoData

func SendNoData(ctx context.Context, sender Sender, r Request) (err error)

SendNoData is a convenience func that executes the given Call using the provided Sender and always drops the response data.

func SetLoggingLevel

func SetLoggingLevel(level uint32, d time.Duration) *agent.Call

func UpdateResourceProviderConfig

func UpdateResourceProviderConfig(rpi mesos.ResourceProviderInfo) *agent.Call

func WaitContainer

func WaitContainer(cid mesos.ContainerID) *agent.Call

func WaitNestedContainer

func WaitNestedContainer(cid mesos.ContainerID) *agent.Call

Types

type Request

type Request interface {
	Call() *agent.Call
}

Request generates a Call that's sent to a Mesos agent. Subsequent invocations are expected to yield equivalent calls. Intended for use w/ non-streaming requests to an agent.

type RequestFunc

type RequestFunc func() *agent.Call

RequestFunc is the functional adaptation of Request.

func NonStreaming

func NonStreaming(c *agent.Call) RequestFunc

NonStreaming returns a RequestFunc that always generates the same Call.

func (RequestFunc) Call

func (f RequestFunc) Call() *agent.Call

func (RequestFunc) Marshaler

func (f RequestFunc) Marshaler() encoding.Marshaler

type RequestStreaming

type RequestStreaming interface {
	Request
	IsStreaming()
}

RequestStreaming generates a Call that's send to a Mesos agent. Subsequent invocations MAY generate different Call objects. No more Call objects are expected once a nil is returned to signal the end of of the request stream.

type RequestStreamingFunc

type RequestStreamingFunc func() *agent.Call

RequestStreamingFunc is the functional adaptation of RequestStreaming.

func Empty

func Empty() RequestStreamingFunc

Empty generates a stream that always returns nil.

func FromChan

func FromChan(ch <-chan *agent.Call) RequestStreamingFunc

FromChan returns a streaming request that fetches calls from the given channel until it closes. If a nil chan is specified then the returned func will always generate nil.

func Push

Push prepends one or more calls onto a request stream. If no calls are given then the original stream is returned.

func (RequestStreamingFunc) Call

func (f RequestStreamingFunc) Call() *agent.Call

func (RequestStreamingFunc) IsStreaming

func (f RequestStreamingFunc) IsStreaming()

func (RequestStreamingFunc) Marshaler

func (f RequestStreamingFunc) Marshaler() encoding.Marshaler

func (RequestStreamingFunc) Push

type Sender

type Sender interface {
	Send(context.Context, Request) (mesos.Response, error)
}

Send issues a Request to a Mesos agent and properly manages Call-specific mechanics.

type SenderFunc

type SenderFunc func(context.Context, Request) (mesos.Response, error)

SenderFunc is the functional adaptation of the Sender interface

func IgnoreResponse

func IgnoreResponse(s Sender) SenderFunc

IgnoreResponse generates a sender that closes any non-nil response received by Mesos.

func (SenderFunc) Send

func (f SenderFunc) Send(ctx context.Context, r Request) (mesos.Response, error)

Send implements the Sender interface for SenderFunc

Jump to

Keyboard shortcuts

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