realis

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2016 License: Apache-2.0 Imports: 14 Imported by: 0

README

gorealis GoDoc

Go library for communicating with Apache Aurora. Named after the northern lights (Aurora Borealis).

Aurora version compatibility

Please see .auroraversion to see the latest Aurora version against which this library has been tested. Vendoring a working version of this library is highly recommended.

Usage

To Do

Importing

  • We suggest using a vendoring tool such as govendor and fetching by version, for example: govendor fetch github.com/rdelval/gorealis@v1

Contributions

Contributions are very much welcome. Please raise an issue so that the contribution may be discussed before it's made.

Documentation

Overview

Collection of monitors to create synchronicity

Package realis provides the ability to use Thrift API to communicate with Apache Aurora.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBasicAuth

func AddBasicAuth(config *RealisConfig, username string, password string)

Helper function to add basic authorization needed to communicate with Apache Aurora.

func LeaderFromZK

func LeaderFromZK(cluster Cluster) (string, error)

Loads leader from ZK endpoint.

func LoadClusters

func LoadClusters(config string) (map[string]Cluster, error)

Loads clusters.json file traditionally located at /etc/aurora/clusters.json

Types

type AuroraJob

type AuroraJob struct {
	// contains filtered or unexported fields
}

Structure to collect all information pertaining to an Aurora job.

func (AuroraJob) AddLabel

func (j AuroraJob) AddLabel(key string, value string) Job

Adds a Mesos label to the job. Note that Aurora will add the prefix "org.apache.aurora.metadata." to the beginning of each key.

func (AuroraJob) AddLimitConstraint

func (j AuroraJob) AddLimitConstraint(name string, limit int32) Job

From Aurora Docs: A constraint that specifies the maximum number of active tasks on a host with a matching attribute that may be scheduled simultaneously.

func (AuroraJob) AddNamedPorts

func (j AuroraJob) AddNamedPorts(names ...string) Job

Add a named port to the job configuration These are random ports as it's not currently possible to request specific ports using Aurora.

func (AuroraJob) AddPorts

func (j AuroraJob) AddPorts(num int) Job

Adds a request for a number of ports to the job configuration. The names chosen for these ports will be org.apache.aurora.port.X, where X is the current port count for the job configuration starting at 0. These are random ports as it's not currently possible to request specific ports using Aurora.

func (AuroraJob) AddURIs

func (j AuroraJob) AddURIs(extract bool, cache bool, values ...string) Job

Add a list of URIs with the same extract and cache configuration. Scheduler must have --enable_mesos_fetcher flag enabled. Currently there is no duplicate detection.

func (AuroraJob) AddValueConstraint

func (j AuroraJob) AddValueConstraint(name string, negated bool, values ...string) Job

From Aurora Docs: Add a Value constraint name - Mesos slave attribute that the constraint is matched against. If negated = true , treat this as a 'not' - to avoid specific values. Values - list of values we look for in attribute name

func (AuroraJob) CPU

func (j AuroraJob) CPU(cpus float64) Job

func (AuroraJob) Container added in v1.0.2

func (j AuroraJob) Container(container Container) Job

Set a container to run for the job configuration to run. TODO (rdelvalle): Add no thermos mode where container is launched as a task and not an executor.

func (AuroraJob) CronCollisionPolicy

func (j AuroraJob) CronCollisionPolicy(policy aurora.CronCollisionPolicy) Job

func (AuroraJob) CronSchedule

func (j AuroraJob) CronSchedule(cron string) Job

func (AuroraJob) Disk

func (j AuroraJob) Disk(disk int64) Job

func (AuroraJob) Environment

func (j AuroraJob) Environment(env string) Job

Set Job Key environment.

func (AuroraJob) ExecutorData

func (j AuroraJob) ExecutorData(data string) Job

Will be included as part of entire task inside the scheduler that will be serialized.

func (AuroraJob) ExecutorName

func (j AuroraJob) ExecutorName(name string) Job

Set name of the executor that will the task will be configured to.

func (AuroraJob) GetInstanceCount

func (j AuroraJob) GetInstanceCount() int32

How many instances of the job to run

func (AuroraJob) InstanceCount

func (j AuroraJob) InstanceCount(instCount int32) Job

How many instances of the job to run

func (AuroraJob) IsService

func (j AuroraJob) IsService(isService bool) Job

Restart the job's tasks if they fail

func (AuroraJob) JobConfig

func (j AuroraJob) JobConfig() *aurora.JobConfiguration

Get the current job configurations key to use for some realis calls.

func (AuroraJob) JobKey

func (j AuroraJob) JobKey() *aurora.JobKey

Get the current job configurations key to use for some realis calls.

func (AuroraJob) MaxFailure

func (j AuroraJob) MaxFailure(maxFail int32) Job

How many failures to tolerate before giving up.

func (AuroraJob) Name

func (j AuroraJob) Name(name string) Job

Set Job Key Name.

func (AuroraJob) RAM

func (j AuroraJob) RAM(ram int64) Job

func (AuroraJob) Role

func (j AuroraJob) Role(role string) Job

Set Job Key Role.

func (AuroraJob) TaskConfig

func (j AuroraJob) TaskConfig() *aurora.TaskConfig

type Cluster

type Cluster struct {
	Name          string `json:"name"`
	AgentRoot     string `json:"slave_root"`
	AgentRunDir   string `json:"slave_run_directory"`
	ZK            string `json:"zk"`
	ZKPort        int    `json:"zk_port"`
	SchedZKPath   string `json:"scheduler_zk_path"`
	SchedURI      string `json:"scheduler_uri"`
	ProxyURL      string `json:"proxy_url"`
	AuthMechanism string `json:"auth_mechanism"`
}

type Container added in v1.0.2

type Container interface {
	Build() *aurora.Container
}

type DockerContainer added in v1.0.2

type DockerContainer struct {
	// contains filtered or unexported fields
}

func NewDockerContainer added in v1.0.2

func NewDockerContainer() DockerContainer

func (DockerContainer) AddParameter added in v1.0.2

func (c DockerContainer) AddParameter(name, value string) DockerContainer

func (DockerContainer) Build added in v1.0.2

func (c DockerContainer) Build() *aurora.Container

func (DockerContainer) Image added in v1.0.2

func (c DockerContainer) Image(image string) DockerContainer

type Endpoint

type Endpoint struct {
	Host string `json:"host"`
	Port int    `json:"port"`
}

type Job

type Job interface {
	// Set Job Key environment.
	Environment(env string) Job
	Role(role string) Job
	Name(name string) Job
	CPU(cpus float64) Job
	CronSchedule(cron string) Job
	CronCollisionPolicy(policy aurora.CronCollisionPolicy) Job
	Disk(disk int64) Job
	RAM(ram int64) Job
	ExecutorName(name string) Job
	ExecutorData(data string) Job
	AddPorts(num int) Job
	AddLabel(key string, value string) Job
	AddNamedPorts(names ...string) Job
	AddLimitConstraint(name string, limit int32) Job
	AddValueConstraint(name string, negated bool, values ...string) Job
	AddURIs(extract bool, cache bool, values ...string) Job
	JobKey() *aurora.JobKey
	JobConfig() *aurora.JobConfiguration
	TaskConfig() *aurora.TaskConfig
	IsService(isService bool) Job
	InstanceCount(instCount int32) Job
	GetInstanceCount() int32
	MaxFailure(maxFail int32) Job
	Container(container Container) Job
}

func NewJob

func NewJob() Job

Create a Job object with everything initialized.

type MesosContainer added in v1.0.2

type MesosContainer struct {
	// contains filtered or unexported fields
}

TODO(rdelvalle): Implement Mesos container builder

type Monitor

type Monitor struct {
	Client Realis
}

func (*Monitor) Instances

func (m *Monitor) Instances(key *aurora.JobKey, instances int32, interval int, timeout int) (bool, error)

func (*Monitor) JobUpdate

func (m *Monitor) JobUpdate(updateKey aurora.JobUpdateKey, interval int, timeout int) bool

Polls the scheduler every certain amount of time to see if the update has succeeded

type NoopLogger added in v1.0.4

type NoopLogger struct{}

func (NoopLogger) Printf added in v1.0.4

func (NoopLogger) Printf(format string, a ...interface{})

type Realis

type Realis interface {
	AbortJobUpdate(updateKey aurora.JobUpdateKey, message string) (*aurora.Response, error)
	AddInstances(instKey aurora.InstanceKey, count int32) (*aurora.Response, error)
	CreateJob(auroraJob Job) (*aurora.Response, error)
	DescheduleCronJob(key *aurora.JobKey) (*aurora.Response, error)
	FetchTaskConfig(instKey aurora.InstanceKey) (*aurora.TaskConfig, error)
	GetInstanceIds(key *aurora.JobKey, states map[aurora.ScheduleStatus]bool) (map[int32]bool, error)
	JobUpdateDetails(updateQuery aurora.JobUpdateQuery) (*aurora.Response, error)
	KillJob(key *aurora.JobKey) (*aurora.Response, error)
	KillInstances(key *aurora.JobKey, instances ...int32) (*aurora.Response, error)
	RestartInstances(key *aurora.JobKey, instances ...int32) (*aurora.Response, error)
	RestartJob(key *aurora.JobKey) (*aurora.Response, error)
	RollbackJobUpdate(key aurora.JobUpdateKey, message string) (*aurora.Response, error)
	ScheduleCronJob(auroraJob Job) (*aurora.Response, error)
	StartJobUpdate(updateJob *UpdateJob, message string) (*aurora.Response, error)
	StartCronJob(key *aurora.JobKey) (*aurora.Response, error)
	Close()
}

func NewClient

func NewClient(config RealisConfig) Realis

Create a new Client with a default transport layer

type RealisConfig

type RealisConfig struct {
	// contains filtered or unexported fields
}

Wrap object to provide future flexibility

func NewDefaultConfig

func NewDefaultConfig(url string) (RealisConfig, error)

Create a default configuration of the transport layer, requires a URL to test connection with.

type ServiceInstance

type ServiceInstance struct {
	Service             Endpoint            `json:"serviceEndpoint"`
	AdditionalEndpoints map[string]Endpoint `json:"additionalEndpoints"`
	Status              string              `json:"status"`
}

type UpdateJob

type UpdateJob struct {
	Job // SetInstanceCount for job is hidden, access via full qualifier
	// contains filtered or unexported fields
}

Structure to collect all information required to create job update

func NewUpdateJob

func NewUpdateJob(config *aurora.TaskConfig) *UpdateJob

Create a default UpdateJob object.

func (*UpdateJob) BatchSize

func (u *UpdateJob) BatchSize(size int32) *UpdateJob

Max number of instances being updated at any given moment.

func (*UpdateJob) InstanceCount

func (u *UpdateJob) InstanceCount(inst int32) *UpdateJob

Set instance count the job will have after the update.

func (*UpdateJob) MaxFailedInstances

func (u *UpdateJob) MaxFailedInstances(inst int32) *UpdateJob

Max number of FAILED instances to tolerate before terminating the update.

func (*UpdateJob) MaxPerInstanceFailures

func (u *UpdateJob) MaxPerInstanceFailures(inst int32) *UpdateJob

Max number of instance failures to tolerate before marking instance as FAILED.

func (*UpdateJob) RollbackOnFail

func (u *UpdateJob) RollbackOnFail(rollback bool) *UpdateJob

When False, prevents auto rollback of a failed update.

func (*UpdateJob) WaitForBatchCompletion

func (u *UpdateJob) WaitForBatchCompletion(batchWait bool) *UpdateJob

Wait for all instances in a group to be done before moving on.

func (*UpdateJob) WatchTime

func (u *UpdateJob) WatchTime(milliseconds int32) *UpdateJob

Minimum number of seconds a shard must remain in RUNNING state before considered a success.

Directories

Path Synopsis
gen-go
Helper functions to process aurora.Response
Helper functions to process aurora.Response

Jump to

Keyboard shortcuts

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