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: 7 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(c *master.Call) { swallow(sender.Send(ctx, NonStreaming(c))) }

	d = time.Duration(0)
)
blackhole(GetHealth())
blackhole(GetFlags())
blackhole(GetVersion())
blackhole(GetMetrics(nil))
blackhole(GetMetrics(&d))
blackhole(GetLoggingLevel())
blackhole(ListFiles(""))
blackhole(ReadFile("", 0))
blackhole(ReadFileWithLength("", 0, 0))
blackhole(GetState())
blackhole(GetAgents())
blackhole(GetFrameworks())
blackhole(GetExecutors())
blackhole(GetOperations())
blackhole(GetTasks())
blackhole(GetRoles())
blackhole(GetWeights())
blackhole(GetMaster())
blackhole(GetMaintenanceStatus())
blackhole(GetMaintenanceSchedule())
blackhole(GetQuota())
blackhole(Subscribe())

blackhole = func(c *master.Call) {
	check(SendNoData(ctx, sender, NonStreaming(c)))
}
blackhole(SetLoggingLevel(0, 0))
blackhole(UpdateWeights())
blackhole(ReserveResources(mesos.AgentID{}))
blackhole(UnreserveResources(mesos.AgentID{}))
blackhole(CreateVolumes(mesos.AgentID{}))
blackhole(DestroyVolumes(mesos.AgentID{}))
blackhole(GrowVolume(&mesos.AgentID{}, mesos.Resource{}, mesos.Resource{}))
blackhole(ShrinkVolume(&mesos.AgentID{}, mesos.Resource{}, mesos.Value_Scalar{}))
blackhole(UpdateMaintenanceSchedule(maintenance.Schedule{}))
blackhole(StartMaintenance())
blackhole(StopMaintenance())
blackhole(SetQuota(quota.QuotaRequest{}))
blackhole(RemoveQuota(""))
blackhole(MarkAgentGone(mesos.AgentID{}))
blackhole(Teardown(mesos.FrameworkID{}))
blackhole(DrainAgent(mesos.AgentID{}))
blackhole(DeactivateAgent(mesos.AgentID{}))
blackhole(ReactivateAgent(mesos.AgentID{}))
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateVolumes

func CreateVolumes(a mesos.AgentID, v ...mesos.Resource) *master.Call

CreateVolumes creates persistent volumes on reserved resources. The request is forwarded asynchronously to the Mesos agent where the reserved resources are located. That asynchronous message may not be delivered or creating the volumes at the agent might fail.

func DeactivateAgent

func DeactivateAgent(a mesos.AgentID) *master.Call

DeactivateAgent turns off offers for a specific agent. A deactivated agent will continue to run tasks and communicate statuses with the master. EXPERIMENTAL.

func DestroyVolumes

func DestroyVolumes(a mesos.AgentID, v ...mesos.Resource) *master.Call

DestroyVolumes destroys persistent volumes. The request is forwarded asynchronously to the Mesos agent where the reserved resources are located.

func DrainAgent

func DrainAgent(a mesos.AgentID, options ...func(*master.Call_DrainAgent)) *master.Call

DrainAgent marks an agent for automated draining of tasks. This prevents further tasks from being launched on the agent, by preventing offers from being sent for the agent (see 'DeactivateAgent'), and also begins killing tasks running on the agent. EXPERIMENTAL.

func GetAgents

func GetAgents() *master.Call

GetAgents retrieves information about all the agents known to the master.

func GetExecutors

func GetExecutors() *master.Call

GetExecutors retrieves information about all the executors known to the master.

func GetFlags

func GetFlags() *master.Call

GetFlags retrieves the master's overall flag configuration.

func GetFrameworks

func GetFrameworks() *master.Call

GetFrameworks retrieves information about all the frameworks known to the master.

func GetHealth

func GetHealth() *master.Call

GetHealth retrieves the health status of master.

func GetLoggingLevel

func GetLoggingLevel() *master.Call

GetLoggingLevel retrieves the master's logging level.

func GetMaintenanceSchedule

func GetMaintenanceSchedule() *master.Call

GetMaintenanceSchedule retrieves the cluster's maintenance schedule.

func GetMaintenanceStatus

func GetMaintenanceStatus() *master.Call

GetMaintenanceStatus retrieves the cluster's maintenance status.

func GetMaster

func GetMaster() *master.Call

GetMaster retrieves information about the master.

func GetMetrics

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

GetMetrics gives the snapshot of current metrics to the end user. If timeout is set in the call, it will be used to determine the maximum amount of time the API will take to respond. If the timeout is exceeded, some metrics may not be included in the response.

func GetOperations

func GetOperations() *master.Call

GetOperations retrieves information about all the operations known to the master.

func GetQuota

func GetQuota() *master.Call

GetQuota retrieves the cluster's configured quotas.

func GetRoles

func GetRoles() *master.Call

GetRoles retrieves information about all the roles known to the master.

func GetState

func GetState() *master.Call

GetState retrieves the overall cluster state.

func GetTasks

func GetTasks() *master.Call

GetTasks retrieves information about all the tasks known to the master.

func GetVersion

func GetVersion() *master.Call

GetVersion retrieves the master's version information.

func GetWeights

func GetWeights() *master.Call

GetWeights retrieves the information about role weights.

func GrowVolume

func GrowVolume(a *mesos.AgentID, volume, addition mesos.Resource) *master.Call

GrowVolume grows a persistent volume on an agent's ROOT or PATH disks. The request is forwarded asynchronously to the Mesos agent where the persistent volume is located.

func ListFiles

func ListFiles(path string) *master.Call

ListFiles retrieves the file listing for a directory in master.

func MarkAgentGone

func MarkAgentGone(id mesos.AgentID) *master.Call

MarkAgentGone removes the quota for a particular role.

func ReactivateAgent

func ReactivateAgent(a mesos.AgentID) *master.Call

ReactivateAgent turns on offers for a specific agent, which was previously drained or deactivated. EXPERIMENTAL.

func ReadFile

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

ReadFile reads data from a file on the master. This call takes the path of the file to be read and the offset to start reading.

func ReadFileWithLength

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

ReadFileWithLength is similar to ReadFile but species the maximum number of bytes to read from the file.

func RemoveQuota

func RemoveQuota(role string) *master.Call

RemoveQuota removes the quota for a particular role.

func ReserveResources

func ReserveResources(a mesos.AgentID, r ...mesos.Resource) *master.Call

ReserveResources reserves resources dynamically on a specific agent.

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) *master.Call

SetLoggingLevel sets the logging verbosity level for a specified duration for master. Mesos uses glog for logging. The library only uses verbose logging which means nothing will be output unless the verbosity level is set (by default it's 0, libprocess uses levels 1, 2, and 3).

func SetQuota

func SetQuota(qr quota.QuotaRequest) *master.Call

SetQuota sets the quota for resources to be used by a particular role.

func ShrinkVolume

func ShrinkVolume(a *mesos.AgentID, volume mesos.Resource, subtract mesos.Value_Scalar) *master.Call

ShrinkVolume shrinks a persistent volume on an agent's ROOT or PATH disks. The request is forwarded asynchronously to the Mesos agent where the persistent volume is located.

func StartMaintenance

func StartMaintenance(m ...mesos.MachineID) *master.Call

StartMaintenance starts the maintenance of the cluster, this would bring a set of machines down.

func StopMaintenance

func StopMaintenance(m ...mesos.MachineID) *master.Call

StopMaintenance stops the maintenance of the cluster, this would bring a set of machines back up.

func Subscribe

func Subscribe() *master.Call

Subscribe results in a streaming response. The client is expected to keep a persistent connection open to the endpoint even after getting a SUBSCRIBED HTTP Response event. This is indicated by "Connection: keep-alive" and "Transfer-Encoding: chunked" headers with no "Content-Length" header set. All subsequent events generated by Mesos are streamed on this connection. The master encodes each Event in RecordIO format, i.e., string representation of length of the event in bytes followed by JSON or binary Protobuf encoded event.

func Teardown

func Teardown(id mesos.FrameworkID) *master.Call

Teardown removes the quota for a particular role.

func UnreserveResources

func UnreserveResources(a mesos.AgentID, r ...mesos.Resource) *master.Call

UnreserveResources unreserves resources dynamically on a specific agent.

func UpdateMaintenanceSchedule

func UpdateMaintenanceSchedule(s maintenance.Schedule) *master.Call

UpdateMaintenanceSchedule updates the cluster's maintenance schedule.

func UpdateWeights

func UpdateWeights(weights ...mesos.WeightInfo) *master.Call

UpdateWeights updates weights for specific roles.

Types

type Request

type Request interface {
	Call() *master.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() *master.Call

RequestFunc is the functional adaptation of Request.

func NonStreaming

func NonStreaming(c *master.Call) RequestFunc

NonStreaming returns a RequestFunc that always generates the same Call.

func (RequestFunc) Call

func (f RequestFunc) Call() *master.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() *master.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 *master.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() *master.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