├── .gitmodules ├── api ├── v1 │ ├── docker │ │ ├── .gitignore │ │ ├── README.md │ │ ├── Dockerfile │ │ ├── marathon.json │ │ └── Makefile │ ├── cmd │ │ ├── mwatch │ │ │ └── doc.go │ │ ├── version.go │ │ ├── example-executor │ │ │ └── debug.go │ │ ├── example-scheduler │ │ │ ├── main.go │ │ │ └── app │ │ │ │ ├── control.go │ │ │ │ ├── env.go │ │ │ │ └── server.go │ │ ├── vendor │ │ │ └── golang.org │ │ │ │ └── x │ │ │ │ └── net │ │ │ │ └── context │ │ │ │ └── withtimeout_test.go │ │ └── msh │ │ │ └── msh.go │ ├── lib │ │ ├── doc.go │ │ ├── agent │ │ │ └── calls │ │ │ │ └── gen.go │ │ ├── master │ │ │ └── calls │ │ │ │ └── gen.go │ │ ├── scheduler │ │ │ ├── calls │ │ │ │ ├── gen.go │ │ │ │ ├── errors.go │ │ │ │ ├── calls_generated.go │ │ │ │ └── calls_test.go │ │ │ ├── events │ │ │ │ └── gen.go │ │ │ └── options.go │ │ ├── encoding │ │ │ ├── proto │ │ │ │ ├── doc.go │ │ │ │ ├── encoding.go │ │ │ │ └── encoding_test.go │ │ │ ├── json │ │ │ │ └── json.go │ │ │ ├── codecs │ │ │ │ └── codecs.go │ │ │ └── framing │ │ │ │ ├── decoder.go │ │ │ │ └── framing.go │ │ ├── executor │ │ │ ├── events │ │ │ │ └── gen.go │ │ │ ├── calls │ │ │ │ ├── gen.go │ │ │ │ ├── calls_caller_generated.go │ │ │ │ └── calls.go │ │ │ └── options.go │ │ ├── httpcli │ │ │ ├── httpagent │ │ │ │ ├── gen.go │ │ │ │ ├── util_test.go │ │ │ │ ├── httpagent_generated.go │ │ │ │ ├── util.go │ │ │ │ └── httpagent_generated_test.go │ │ │ ├── httpexec │ │ │ │ ├── gen.go │ │ │ │ ├── util.go │ │ │ │ ├── httpexec_generated.go │ │ │ │ └── httpexec_generated_test.go │ │ │ ├── httpmaster │ │ │ │ ├── gen.go │ │ │ │ ├── util_test.go │ │ │ │ ├── httpmaster_generated.go │ │ │ │ ├── httpmaster_generated_test.go │ │ │ │ └── util.go │ │ │ ├── auth_basic.go │ │ │ ├── opts.go │ │ │ └── apierrors │ │ │ │ └── apierrors_test.go │ │ ├── debug │ │ │ └── logger.go │ │ ├── recordio │ │ │ ├── doc.go │ │ │ ├── writer.go │ │ │ └── writer_test.go │ │ ├── resources_bench_test.go │ │ ├── filters.go │ │ ├── extras │ │ │ ├── executor │ │ │ │ ├── eventrules │ │ │ │ │ ├── gen.go │ │ │ │ │ ├── metrics_generated.go │ │ │ │ │ ├── handlers_generated.go │ │ │ │ │ └── metrics_generated_test.go │ │ │ │ └── callrules │ │ │ │ │ ├── gen.go │ │ │ │ │ ├── metrics_generated.go │ │ │ │ │ ├── callers_generated.go │ │ │ │ │ └── metrics_generated_test.go │ │ │ ├── scheduler │ │ │ │ ├── eventrules │ │ │ │ │ ├── gen.go │ │ │ │ │ ├── metrics_generated.go │ │ │ │ │ ├── handlers_generated.go │ │ │ │ │ └── metrics_generated_test.go │ │ │ │ ├── callrules │ │ │ │ │ ├── gen.go │ │ │ │ │ ├── helpers.go │ │ │ │ │ ├── metrics_generated.go │ │ │ │ │ ├── callers_generated.go │ │ │ │ │ └── metrics_generated_test.go │ │ │ │ └── offers │ │ │ │ │ └── filters.go │ │ │ ├── latch │ │ │ │ ├── latch_test.go │ │ │ │ └── latch.go │ │ │ ├── gen │ │ │ │ ├── callers.go │ │ │ │ ├── rule_handlers.go │ │ │ │ └── rule_callers.go │ │ │ └── metrics │ │ │ │ └── metrics.go │ │ ├── resources │ │ │ ├── names.go │ │ │ ├── find.go │ │ │ ├── compare.go │ │ │ └── reduce.go │ │ ├── fixedpoint.go │ │ ├── time │ │ │ └── time_test.go │ │ ├── client │ │ │ └── client.go │ │ ├── labels.go │ │ └── roles │ │ │ └── role.go │ └── doc.go ├── v0 │ ├── examples │ │ ├── Godeps │ │ │ ├── _workspace │ │ │ │ ├── .gitignore │ │ │ │ └── src │ │ │ │ │ ├── github.com │ │ │ │ │ ├── stretchr │ │ │ │ │ │ ├── objx │ │ │ │ │ │ │ ├── value_test.go │ │ │ │ │ │ │ ├── README.md │ │ │ │ │ │ │ ├── security_test.go │ │ │ │ │ │ │ ├── map_for_test.go │ │ │ │ │ │ │ ├── security.go │ │ │ │ │ │ │ ├── .gitignore │ │ │ │ │ │ │ ├── value.go │ │ │ │ │ │ │ ├── constants.go │ │ │ │ │ │ │ ├── codegen │ │ │ │ │ │ │ │ ├── array-access.txt │ │ │ │ │ │ │ │ ├── types_list.txt │ │ │ │ │ │ │ │ └── index.html │ │ │ │ │ │ │ ├── tests.go │ │ │ │ │ │ │ ├── tests_test.go │ │ │ │ │ │ │ ├── LICENSE.md │ │ │ │ │ │ │ ├── simple_example_test.go │ │ │ │ │ │ │ ├── conversions_test.go │ │ │ │ │ │ │ └── mutations_test.go │ │ │ │ │ │ └── testify │ │ │ │ │ │ │ ├── assert │ │ │ │ │ │ │ └── errors.go │ │ │ │ │ │ │ └── mock │ │ │ │ │ │ │ └── doc.go │ │ │ │ │ ├── pborman │ │ │ │ │ │ └── uuid │ │ │ │ │ │ │ ├── CONTRIBUTORS │ │ │ │ │ │ │ ├── doc.go │ │ │ │ │ │ │ ├── json_test.go │ │ │ │ │ │ │ ├── json.go │ │ │ │ │ │ │ ├── version4.go │ │ │ │ │ │ │ ├── version1.go │ │ │ │ │ │ │ ├── LICENSE │ │ │ │ │ │ │ ├── seq_test.go │ │ │ │ │ │ │ ├── hash.go │ │ │ │ │ │ │ └── util.go │ │ │ │ │ ├── golang │ │ │ │ │ │ └── glog │ │ │ │ │ │ │ └── README │ │ │ │ │ └── gogo │ │ │ │ │ │ └── protobuf │ │ │ │ │ │ └── proto │ │ │ │ │ │ ├── lib_gogo.go │ │ │ │ │ │ ├── testdata │ │ │ │ │ │ └── Makefile │ │ │ │ │ │ ├── Makefile │ │ │ │ │ │ └── text_gogo.go │ │ │ │ │ └── golang.org │ │ │ │ │ └── x │ │ │ │ │ └── net │ │ │ │ │ └── context │ │ │ │ │ ├── ctxhttp │ │ │ │ │ ├── cancelreq.go │ │ │ │ │ ├── cancelreq_go14.go │ │ │ │ │ └── ctxhttp_test.go │ │ │ │ │ └── withtimeout_test.go │ │ │ ├── Readme │ │ │ └── Godeps.json │ │ ├── Makefile │ │ ├── zkdetect │ │ │ └── main.go │ │ ├── README.md │ │ └── flagcheck │ │ │ └── flagcheck.go │ ├── upid │ │ ├── doc.go │ │ ├── upid_test.go │ │ └── upid.go │ ├── mesosutil │ │ ├── constants.go │ │ ├── process │ │ │ └── process.go │ │ └── node.go │ ├── detector │ │ ├── zoo │ │ │ ├── doc.go │ │ │ ├── plugin.go │ │ │ ├── plugin_test.go │ │ │ ├── types.go │ │ │ ├── client2.go │ │ │ └── mock │ │ │ │ └── conn.go │ │ ├── doc.go │ │ └── factory_test.go │ ├── messenger │ │ ├── testmessage │ │ │ ├── Makefile │ │ │ ├── testmessage.proto │ │ │ └── generator.go │ │ ├── doc.go │ │ ├── sessionid │ │ │ └── sessionid.go │ │ ├── message.go │ │ ├── transporter.go │ │ └── README.md │ ├── executor │ │ ├── doc.go │ │ └── testing.go │ ├── scheduler │ │ ├── plugins.go │ │ ├── doc.go │ │ ├── handler.go │ │ ├── mock │ │ │ └── scheduler.go │ │ └── testing.go │ ├── auth │ │ ├── callback │ │ │ ├── name.go │ │ │ ├── password.go │ │ │ ├── interprocess.go │ │ │ └── interface.go │ │ └── sasl │ │ │ ├── mock │ │ │ └── mock.go │ │ │ ├── mech │ │ │ ├── plugins.go │ │ │ ├── interface.go │ │ │ └── crammd5 │ │ │ │ └── mechanism.go │ │ │ └── context.go │ ├── mesosproto │ │ ├── Makefile │ │ ├── internal.proto │ │ └── authentication.proto │ ├── README.md │ └── healthchecker │ │ └── health_checker.go └── doc.go ├── .gitignore ├── NOTICE ├── .travis.yml └── CONTRIBUTING.md /.gitmodules: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /api/v1/docker/.gitignore: -------------------------------------------------------------------------------- 1 | /_output 2 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/.gitignore: -------------------------------------------------------------------------------- 1 | /pkg 2 | /bin 3 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/value_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/pborman/uuid/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | Paul Borman 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /example-scheduler 2 | /example-executor 3 | bin/ 4 | *.bak 5 | *.swp 6 | _output/ 7 | **/vendor/*/ 8 | -------------------------------------------------------------------------------- /api/v0/upid/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package upid defines the UPID type and some utilities of the UPID. 3 | */ 4 | package upid 5 | -------------------------------------------------------------------------------- /api/v1/cmd/mwatch/doc.go: -------------------------------------------------------------------------------- 1 | // mwatch is an example utility that observes events happening on a mesos master. 2 | 3 | package main 4 | -------------------------------------------------------------------------------- /api/v1/cmd/version.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | // DockerImageTag should be populated by the build system 4 | var DockerImageTag = "" 5 | -------------------------------------------------------------------------------- /api/v0/mesosutil/constants.go: -------------------------------------------------------------------------------- 1 | package mesosutil 2 | 3 | const ( 4 | // MesosVersion indicates the supported mesos version. 5 | MesosVersion = "0.24.0" 6 | ) 7 | -------------------------------------------------------------------------------- /api/v0/detector/zoo/doc.go: -------------------------------------------------------------------------------- 1 | // Zookeeper-based mesos-master leaderhip detection. 2 | // Implements support for optional detector.AllMasters interface. 3 | package zoo 4 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/README.md: -------------------------------------------------------------------------------- 1 | # objx 2 | 3 | * Jump into the [API Documentation](http://godoc.org/github.com/stretchr/objx) 4 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /api/v0/messenger/testmessage/Makefile: -------------------------------------------------------------------------------- 1 | all: testmessage.proto 2 | protoc --proto_path=${GOPATH}/src:${GOPATH}/src/github.com/gogo/protobuf/protobuf:. --gogo_out=. testmessage.proto 3 | -------------------------------------------------------------------------------- /api/v1/lib/doc.go: -------------------------------------------------------------------------------- 1 | // Package mesos presents common v1 HTTP API message types in addition to extension APIs that 2 | // aim to simplify use of the machine-generated code. 3 | package mesos 4 | -------------------------------------------------------------------------------- /api/v1/lib/agent/calls/gen.go: -------------------------------------------------------------------------------- 1 | package calls 2 | 3 | //go:generate go run ../../extras/gen/sender.go ../../extras/gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/agent -type C:agent.Call 4 | -------------------------------------------------------------------------------- /api/v0/executor/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package executor includes the interfaces of the mesos executor and 3 | the mesos executor driver, as well as an implementation of the driver. 4 | */ 5 | package executor 6 | -------------------------------------------------------------------------------- /api/v1/lib/master/calls/gen.go: -------------------------------------------------------------------------------- 1 | package calls 2 | 3 | //go:generate go run ../../extras/gen/sender.go ../../extras/gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/master -type C:master.Call 4 | -------------------------------------------------------------------------------- /api/v1/lib/scheduler/calls/gen.go: -------------------------------------------------------------------------------- 1 | package calls 2 | 3 | //go:generate go run ../../extras/gen/callers.go ../../extras/gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/scheduler -type C:*scheduler.Call 4 | -------------------------------------------------------------------------------- /api/v1/docker/README.md: -------------------------------------------------------------------------------- 1 | ## How To 2 | ```sh 3 | $ docker run -ti --rm --net=host jdef/example-scheduler-httpv1 -server.address=10.2.0.5 \ 4 | -url=http://10.2.0.7:5050/api/v1/scheduler -tasks=10 -verbose 5 | ``` 6 | -------------------------------------------------------------------------------- /api/v1/lib/encoding/proto/doc.go: -------------------------------------------------------------------------------- 1 | // Package proto implements protobuf utilities such as functional options to 2 | // construct complex structs and encoders and decoders composable with 3 | // io.ReadWriters. 4 | package proto 5 | -------------------------------------------------------------------------------- /api/v0/scheduler/plugins.go: -------------------------------------------------------------------------------- 1 | package scheduler 2 | 3 | import ( 4 | _ "github.com/mesos/mesos-go/api/v0/auth/sasl" 5 | _ "github.com/mesos/mesos-go/api/v0/auth/sasl/mech/crammd5" 6 | _ "github.com/mesos/mesos-go/api/v0/detector/zoo" 7 | ) 8 | -------------------------------------------------------------------------------- /api/v0/scheduler/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package scheduler includes the interfaces for the mesos scheduler and 3 | the mesos executor driver. It also contains as well as an implementation 4 | of the driver that you can use in your code. 5 | */ 6 | package scheduler 7 | -------------------------------------------------------------------------------- /api/v1/lib/executor/events/gen.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | //go:generate go run ../../extras/gen/handlers.go ../../extras/gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/executor -type E:*executor.Event:&executor.Event{} -type ET:executor.Event_Type 4 | -------------------------------------------------------------------------------- /api/v1/lib/scheduler/events/gen.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | //go:generate go run ../../extras/gen/handlers.go ../../extras/gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/scheduler -type E:*scheduler.Event:&scheduler.Event{} -type ET:scheduler.Event_Type 4 | -------------------------------------------------------------------------------- /api/v0/examples/Makefile: -------------------------------------------------------------------------------- 1 | BIN := persistent_scheduler scheduler executor zkdetect flagcheck 2 | RACE := -race 3 | 4 | .PHONY: 5 | .PHONY: all $(BIN) 6 | 7 | all: $(BIN) 8 | 9 | $(BIN): 10 | mkdir -p _output 11 | godep go build $(RACE) -o _output/$@ ./$@ 12 | -------------------------------------------------------------------------------- /api/v0/messenger/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package messenger includes a messenger and a transporter. 3 | The messenger provides interfaces to send a protobuf message 4 | through the underlying transporter. It also dispatches messages 5 | to installed handlers. 6 | */ 7 | package messenger 8 | -------------------------------------------------------------------------------- /api/v0/auth/callback/name.go: -------------------------------------------------------------------------------- 1 | package callback 2 | 3 | type Name struct { 4 | name string 5 | } 6 | 7 | func NewName() *Name { 8 | return &Name{} 9 | } 10 | 11 | func (cb *Name) Get() string { 12 | return cb.name 13 | } 14 | 15 | func (cb *Name) Set(name string) { 16 | cb.name = name 17 | } 18 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/httpagent/gen.go: -------------------------------------------------------------------------------- 1 | package httpagent 2 | 3 | //go:generate go run ../../extras/gen/httpsender.go ../../extras/gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/agent -import github.com/mesos/mesos-go/api/v1/lib/agent/calls -type C:agent.Call:agent.Call{Type:agent.Call_GET_METRICS} 4 | -------------------------------------------------------------------------------- /api/v1/lib/debug/logger.go: -------------------------------------------------------------------------------- 1 | package debug 2 | 3 | import "log" 4 | 5 | type Logger bool 6 | 7 | func (d Logger) Log(v ...interface{}) { 8 | if d { 9 | log.Print(v...) 10 | } 11 | } 12 | 13 | func (d Logger) Logf(s string, v ...interface{}) { 14 | if d { 15 | log.Printf(s, v...) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/httpexec/gen.go: -------------------------------------------------------------------------------- 1 | package httpexec 2 | 3 | //go:generate go run ../../extras/gen/httpsender.go ../../extras/gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/executor -import github.com/mesos/mesos-go/api/v1/lib/executor/calls -type C:executor.Call:executor.Call{Type:executor.Call_MESSAGE} 4 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/httpmaster/gen.go: -------------------------------------------------------------------------------- 1 | package httpmaster 2 | 3 | //go:generate go run ../../extras/gen/httpsender.go ../../extras/gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/master -import github.com/mesos/mesos-go/api/v1/lib/master/calls -type C:master.Call:master.Call{Type:master.Call_GET_METRICS} 4 | -------------------------------------------------------------------------------- /api/v1/cmd/example-executor/debug.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const debug = false 4 | 5 | type marshalJSON interface { 6 | MarshalJSON() ([]byte, error) 7 | } 8 | 9 | func debugJSON(mk marshalJSON) { 10 | if debug { 11 | b, err := mk.MarshalJSON() 12 | if err == nil { 13 | println(string(b)) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /api/v1/lib/recordio/doc.go: -------------------------------------------------------------------------------- 1 | // Package recordio implements the Mesos variant of RecordIO framing, whereby 2 | // each record is prefixed by a line that indicates the length of the record in 3 | // decimal ASCII. The bytes of the record immediately follow the length-line. 4 | // Zero-length records are allowed. 5 | package recordio 6 | -------------------------------------------------------------------------------- /api/v1/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gliderlabs/alpine:3.3 2 | MAINTAINER James DeFelice 3 | 4 | cmd [] 5 | entrypoint [ "/opt/example-scheduler", "-executor=/opt/example-executor", "-url=http://leader.mesos:5050/api/v1/scheduler" ] 6 | 7 | workdir /opt 8 | add example-scheduler ./ 9 | add example-executor ./ 10 | -------------------------------------------------------------------------------- /api/v0/detector/zoo/plugin.go: -------------------------------------------------------------------------------- 1 | package zoo 2 | 3 | import ( 4 | "github.com/mesos/mesos-go/api/v0/detector" 5 | ) 6 | 7 | func init() { 8 | detector.Register("zk://", detector.PluginFactory(func(spec string, options ...detector.Option) (detector.Master, error) { 9 | return NewMasterDetector(spec, options...) 10 | })) 11 | } 12 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/security_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestHashWithKey(t *testing.T) { 9 | 10 | assert.Equal(t, "0ce84d8d01f2c7b6e0882b784429c54d280ea2d9", HashWithKey("abc", "def")) 11 | 12 | } 13 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/map_for_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | var TestMap map[string]interface{} = map[string]interface{}{ 4 | "name": "Tyler", 5 | "address": map[string]interface{}{ 6 | "city": "Salt Lake City", 7 | "state": "UT", 8 | }, 9 | "numbers": []interface{}{"one", "two", "three", "four", "five"}, 10 | } 11 | -------------------------------------------------------------------------------- /api/v0/mesosproto/Makefile: -------------------------------------------------------------------------------- 1 | PROTO_PATH := ${GOPATH}/src:. 2 | PROTO_PATH := ${PROTO_PATH}:${GOPATH}/src/github.com/gogo/protobuf/protobuf 3 | PROTO_PATH := ${PROTO_PATH}:${GOPATH}/src/github.com/gogo/protobuf/gogoproto 4 | 5 | .PHONY: all 6 | 7 | all: 8 | protoc --proto_path=${PROTO_PATH} --gogo_out=. *.proto 9 | protoc --proto_path=${PROTO_PATH} --gogo_out=. ./scheduler/*.proto 10 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/pborman/uuid/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // The uuid package generates and inspects UUIDs. 6 | // 7 | // UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security Services. 8 | package uuid 9 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/security.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "crypto/sha1" 5 | "encoding/hex" 6 | ) 7 | 8 | // HashWithKey hashes the specified string using the security 9 | // key. 10 | func HashWithKey(data, key string) string { 11 | hash := sha1.New() 12 | hash.Write([]byte(data + ":" + key)) 13 | return hex.EncodeToString(hash.Sum(nil)) 14 | } 15 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/value.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | // Value provides methods for extracting interface{} data in various 4 | // types. 5 | type Value struct { 6 | // data contains the raw data being managed by this Value 7 | data interface{} 8 | } 9 | 10 | // Data returns the raw data contained by this Value 11 | func (v *Value) Data() interface{} { 12 | return v.data 13 | } 14 | -------------------------------------------------------------------------------- /api/v1/cmd/example-scheduler/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "log" 6 | "os" 7 | 8 | "github.com/mesos/mesos-go/api/v1/cmd/example-scheduler/app" 9 | ) 10 | 11 | func main() { 12 | cfg := app.NewConfig() 13 | fs := flag.NewFlagSet("scheduler", flag.ExitOnError) 14 | cfg.AddFlags(fs) 15 | fs.Parse(os.Args[1:]) 16 | 17 | if err := app.Run(cfg); err != nil { 18 | log.Fatal(err) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/constants.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | const ( 4 | // PathSeparator is the character used to separate the elements 5 | // of the keypath. 6 | // 7 | // For example, `location.address.city` 8 | PathSeparator string = "." 9 | 10 | // SignatureSeparator is the character that is used to 11 | // separate the Base64 string from the security signature. 12 | SignatureSeparator = "_" 13 | ) 14 | -------------------------------------------------------------------------------- /api/v0/auth/callback/password.go: -------------------------------------------------------------------------------- 1 | package callback 2 | 3 | type Password struct { 4 | password []byte 5 | } 6 | 7 | func NewPassword() *Password { 8 | return &Password{} 9 | } 10 | 11 | func (cb *Password) Get() []byte { 12 | clone := make([]byte, len(cb.password)) 13 | copy(clone, cb.password) 14 | return clone 15 | } 16 | 17 | func (cb *Password) Set(password []byte) { 18 | cb.password = make([]byte, len(password)) 19 | copy(cb.password, password) 20 | } 21 | -------------------------------------------------------------------------------- /api/v0/messenger/sessionid/sessionid.go: -------------------------------------------------------------------------------- 1 | package sessionid 2 | 3 | import ( 4 | "golang.org/x/net/context" 5 | ) 6 | 7 | type key int 8 | 9 | const sessionIDKey = 0 10 | 11 | func NewContext(ctx context.Context, sessionID string) context.Context { 12 | return context.WithValue(ctx, sessionIDKey, sessionID) 13 | } 14 | 15 | func FromContext(ctx context.Context) (string, bool) { 16 | sessionID, ok := ctx.Value(sessionIDKey).(string) 17 | return sessionID, ok 18 | } 19 | -------------------------------------------------------------------------------- /api/v1/lib/resources_bench_test.go: -------------------------------------------------------------------------------- 1 | package mesos_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/mesos/mesos-go/api/v1/lib/resourcetest" 7 | ) 8 | 9 | func BenchmarkPrecisionScalarMath(b *testing.B) { 10 | var ( 11 | start = Resources(Resource(Name("cpus"), ValueScalar(1.001))) 12 | current = start.Clone() 13 | ) 14 | for i := 0; i < b.N; i++ { 15 | current = current.Plus(current...).Plus(current...).Minus(current...).Minus(current...) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/codegen/array-access.txt: -------------------------------------------------------------------------------- 1 | case []{1}: 2 | a := object.([]{1}) 3 | if isSet { 4 | a[index] = value.({1}) 5 | } else { 6 | if index >= len(a) { 7 | if panics { 8 | panic(fmt.Sprintf("objx: Index %d is out of range because the []{1} only contains %d items.", index, len(a))) 9 | } 10 | return nil 11 | } else { 12 | return a[index] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/tests.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | // Has gets whether there is something at the specified selector 4 | // or not. 5 | // 6 | // If m is nil, Has will always return false. 7 | func (m Map) Has(selector string) bool { 8 | if m == nil { 9 | return false 10 | } 11 | return !m.Get(selector).IsNil() 12 | } 13 | 14 | // IsNil gets whether the data is nil or not. 15 | func (v *Value) IsNil() bool { 16 | return v == nil || v.data == nil 17 | } 18 | -------------------------------------------------------------------------------- /api/v1/lib/executor/calls/gen.go: -------------------------------------------------------------------------------- 1 | package calls 2 | 3 | // callers.go APIs are deprecated in favor of sender.go APIs 4 | //go:generate go run ../../extras/gen/callers.go ../../extras/gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/executor -type C:*executor.Call -output calls_caller_generated.go 5 | 6 | //go:generate go run ../../extras/gen/sender.go ../../extras/gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/executor -type C:executor.Call -type O:executor.CallOpt -output calls_sender_generated.go 7 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/cancelreq.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.5 6 | 7 | package ctxhttp 8 | 9 | import "net/http" 10 | 11 | func canceler(client *http.Client, req *http.Request) func() { 12 | ch := make(chan struct{}) 13 | req.Cancel = ch 14 | 15 | return func() { 16 | close(ch) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /api/v1/lib/scheduler/calls/errors.go: -------------------------------------------------------------------------------- 1 | package calls 2 | 3 | import ( 4 | "github.com/mesos/mesos-go/api/v1/lib/scheduler" 5 | ) 6 | 7 | // AckError wraps a caller-generated error and tracks the call that failed. 8 | // It may be reported for either a task status ACK error, or an offer operation 9 | // status ACK error. 10 | type AckError struct { 11 | Ack *scheduler.Call // Ack is REQUIRED 12 | Cause error // Cause is REQUIRED 13 | } 14 | 15 | func (err *AckError) Error() string { return err.Cause.Error() } 16 | -------------------------------------------------------------------------------- /api/v0/auth/sasl/mock/mock.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "github.com/gogo/protobuf/proto" 5 | mock_messenger "github.com/mesos/mesos-go/api/v0/messenger/mock" 6 | "github.com/mesos/mesos-go/api/v0/upid" 7 | "github.com/stretchr/testify/mock" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | type Transport struct { 12 | *mock_messenger.Messenger 13 | } 14 | 15 | func (m *Transport) Send(ctx context.Context, upid *upid.UPID, msg proto.Message) error { 16 | return m.Called(mock.Anything, upid, msg).Error(0) 17 | } 18 | -------------------------------------------------------------------------------- /api/v1/cmd/example-scheduler/app/control.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import ( 4 | "log" 5 | "time" 6 | 7 | xmetrics "github.com/mesos/mesos-go/api/v1/lib/extras/metrics" 8 | ) 9 | 10 | func forever(name string, jobRestartDelay time.Duration, counter xmetrics.Counter, f func() error) { 11 | for { 12 | counter(name) 13 | err := f() 14 | if err != nil { 15 | log.Printf("job %q exited with error %+v", name, err) 16 | } else { 17 | log.Printf("job %q exited", name) 18 | } 19 | time.Sleep(jobRestartDelay) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /api/v1/lib/filters.go: -------------------------------------------------------------------------------- 1 | package mesos 2 | 3 | import "time" 4 | 5 | type FilterOpt func(*Filters) 6 | 7 | func (f *Filters) With(opts ...FilterOpt) *Filters { 8 | for _, o := range opts { 9 | o(f) 10 | } 11 | return f 12 | } 13 | 14 | func RefuseSeconds(d time.Duration) FilterOpt { 15 | return func(f *Filters) { 16 | s := d.Seconds() 17 | f.RefuseSeconds = &s 18 | } 19 | } 20 | 21 | func OptionalFilters(fo ...FilterOpt) *Filters { 22 | if len(fo) == 0 { 23 | return nil 24 | } 25 | return (&Filters{}).With(fo...) 26 | } 27 | -------------------------------------------------------------------------------- /api/v0/detector/zoo/plugin_test.go: -------------------------------------------------------------------------------- 1 | package zoo 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mesos/mesos-go/api/v0/detector" 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | // validate plugin registration for zk:// prefix is working 11 | func TestDectorFactoryNew_ZkPrefix(t *testing.T) { 12 | assert := assert.New(t) 13 | m, err := detector.New("zk://127.0.0.1:5050/mesos") 14 | assert.NoError(err) 15 | assert.IsType(&MasterDetector{}, m) 16 | md := m.(*MasterDetector) 17 | t.Logf("canceling detector") 18 | md.Cancel() 19 | } 20 | -------------------------------------------------------------------------------- /api/v0/auth/callback/interprocess.go: -------------------------------------------------------------------------------- 1 | package callback 2 | 3 | import ( 4 | "github.com/mesos/mesos-go/api/v0/upid" 5 | ) 6 | 7 | type Interprocess struct { 8 | client upid.UPID 9 | server upid.UPID 10 | } 11 | 12 | func NewInterprocess() *Interprocess { 13 | return &Interprocess{} 14 | } 15 | 16 | func (cb *Interprocess) Client() upid.UPID { 17 | return cb.client 18 | } 19 | 20 | func (cb *Interprocess) Server() upid.UPID { 21 | return cb.server 22 | } 23 | 24 | func (cb *Interprocess) Set(server, client upid.UPID) { 25 | cb.server = server 26 | cb.client = client 27 | } 28 | -------------------------------------------------------------------------------- /api/v1/lib/executor/options.go: -------------------------------------------------------------------------------- 1 | package executor 2 | 3 | // A CallOpt is a functional option type for Calls. 4 | type CallOpt func(*Call) 5 | 6 | // With applies the given CallOpts to the receiving Call, returning it. 7 | func (c *Call) With(opts ...CallOpt) *Call { 8 | for _, opt := range opts { 9 | opt(c) 10 | } 11 | return c 12 | } 13 | 14 | type CallOptions []CallOpt 15 | 16 | // Copy returns a cloned copy of CallOptions 17 | func (co CallOptions) Copy() CallOptions { 18 | if len(co) == 0 { 19 | return nil 20 | } 21 | x := make(CallOptions, len(co)) 22 | copy(x, co) 23 | return x 24 | } 25 | -------------------------------------------------------------------------------- /api/v1/doc.go: -------------------------------------------------------------------------------- 1 | // Package v1 contains library and example subpackages for working with the Mesos v1 HTTP API. 2 | // Clients should not consume this package directly. 3 | // 4 | // Library 5 | // 6 | // The v1 API is accessible via the "lib" subpackage. Consumers should import 7 | // "github.com/mesos/mesos-go/api/v1/lib" and refer to its funcs and types via the "mesos" package, 8 | // for example `mesos.Resource`. 9 | // 10 | // Examples 11 | // 12 | // See subpackage "cmd" for sample frameworks. 13 | // See directory "docker" for an illustration of framework deployment via Docker and Marathon. 14 | package v1 15 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/httpexec/util.go: -------------------------------------------------------------------------------- 1 | package httpexec 2 | 3 | import ( 4 | "github.com/mesos/mesos-go/api/v1/lib/client" 5 | "github.com/mesos/mesos-go/api/v1/lib/executor" 6 | "github.com/mesos/mesos-go/api/v1/lib/httpcli" 7 | ) 8 | 9 | func classifyResponse(c *executor.Call) (rc client.ResponseClass, err error) { 10 | switch name := executor.Call_Type_name[int32(c.GetType())]; name { 11 | case "", "UNKNOWN": 12 | err = httpcli.ProtocolError("unsupported call type") 13 | default: 14 | rc = client.ResponseClassAuto // TODO(jdef) fix this, ResponseClassAuto is deprecated 15 | } 16 | return 17 | } 18 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2013-2015, Mesosphere, Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/tests_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestHas(t *testing.T) { 9 | 10 | m := New(TestMap) 11 | 12 | assert.True(t, m.Has("name")) 13 | assert.True(t, m.Has("address.state")) 14 | assert.True(t, m.Has("numbers[4]")) 15 | 16 | assert.False(t, m.Has("address.state.nope")) 17 | assert.False(t, m.Has("address.nope")) 18 | assert.False(t, m.Has("nope")) 19 | assert.False(t, m.Has("numbers[5]")) 20 | 21 | m = nil 22 | assert.False(t, m.Has("nothing")) 23 | 24 | } 25 | -------------------------------------------------------------------------------- /api/v0/mesosutil/process/process.go: -------------------------------------------------------------------------------- 1 | package process 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | var ( 9 | pidLock sync.Mutex 10 | pid uint64 11 | ) 12 | 13 | func nextPid() uint64 { 14 | pidLock.Lock() 15 | defer pidLock.Unlock() 16 | pid++ 17 | return pid 18 | } 19 | 20 | //TODO(jdef) add lifecycle funcs 21 | //TODO(jdef) add messaging funcs 22 | type Process struct { 23 | label string 24 | } 25 | 26 | func New(kind string) *Process { 27 | return &Process{ 28 | label: fmt.Sprintf("%s(%d)", kind, nextPid()), 29 | } 30 | } 31 | 32 | func (p *Process) Label() string { 33 | return p.label 34 | } 35 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/cancelreq_go14.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.5 6 | 7 | package ctxhttp 8 | 9 | import "net/http" 10 | 11 | type requestCanceler interface { 12 | CancelRequest(*http.Request) 13 | } 14 | 15 | func canceler(client *http.Client, req *http.Request) func() { 16 | rc, ok := client.Transport.(requestCanceler) 17 | if !ok { 18 | return func() {} 19 | } 20 | return func() { 21 | rc.CancelRequest(req) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /api/v0/auth/callback/interface.go: -------------------------------------------------------------------------------- 1 | package callback 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type Unsupported struct { 8 | Callback Interface 9 | } 10 | 11 | func (uc *Unsupported) Error() string { 12 | return fmt.Sprintf("Unsupported callback <%T>: %v", uc.Callback, uc.Callback) 13 | } 14 | 15 | type Interface interface { 16 | // marker interface 17 | } 18 | 19 | type Handler interface { 20 | // may return an Unsupported error on failure 21 | Handle(callbacks ...Interface) error 22 | } 23 | 24 | type HandlerFunc func(callbacks ...Interface) error 25 | 26 | func (f HandlerFunc) Handle(callbacks ...Interface) error { 27 | return f(callbacks...) 28 | } 29 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/httpagent/util_test.go: -------------------------------------------------------------------------------- 1 | package httpagent 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mesos/mesos-go/api/v1/lib/agent" 7 | ) 8 | 9 | func TestClassifyResponse(t *testing.T) { 10 | _, err := classifyResponse(nil) 11 | if err == nil { 12 | t.Fatal("expected error instead of nil") 13 | } 14 | for _, v := range agent.Call_Type_value { 15 | ct := agent.Call_Type(v) 16 | _, err = classifyResponse(&agent.Call{Type: ct}) 17 | if ct == agent.Call_UNKNOWN { 18 | if err == nil { 19 | t.Fatal("expected error instead of nil") 20 | } 21 | } else { 22 | if err != nil { 23 | t.Fatalf("unexpected error %v", err) 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/httpmaster/util_test.go: -------------------------------------------------------------------------------- 1 | package httpmaster 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mesos/mesos-go/api/v1/lib/master" 7 | ) 8 | 9 | func TestClassifyResponse(t *testing.T) { 10 | _, err := classifyResponse(nil) 11 | if err == nil { 12 | t.Fatal("expected error instead of nil") 13 | } 14 | for _, v := range master.Call_Type_value { 15 | ct := master.Call_Type(v) 16 | _, err = classifyResponse(&master.Call{Type: ct}) 17 | if ct == master.Call_UNKNOWN { 18 | if err == nil { 19 | t.Fatal("expected error instead of nil") 20 | } 21 | } else { 22 | if err != nil { 23 | t.Fatalf("unexpected error %v", err) 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /api/v1/docker/marathon.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "/example-scheduler", 3 | "instances": 1, 4 | "cpus": 2, 5 | "mem": 128, 6 | "env": { 7 | "NUM_TASKS": "10000", 8 | "MESOS_CONNECT_TIMEOUT": "10s", 9 | "MAX_REFUSE_SECONDS": "3s", 10 | "REVIVE_BURST": "5", 11 | "TASK_CPU": "0.1", 12 | "TASK_MEMORY": "0.1", 13 | "EXEC_CPU": "0.9", 14 | "EXEC_MEMORY": "256" 15 | }, 16 | "container": { 17 | "type": "DOCKER", 18 | "docker": { 19 | "image": "jdef/example-scheduler-httpv1", 20 | "network": "HOST", 21 | "forcePullImage": true 22 | } 23 | }, 24 | "upgradeStrategy": { 25 | "minimumHealthCapacity": 0, 26 | "maximumOverCapacity": 0 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /api/v1/lib/recordio/writer.go: -------------------------------------------------------------------------------- 1 | package recordio 2 | 3 | import ( 4 | "io" 5 | "strconv" 6 | ) 7 | 8 | var lf = []byte{'\n'} 9 | 10 | type Writer struct { 11 | out io.Writer 12 | } 13 | 14 | func NewWriter(out io.Writer) *Writer { 15 | return &Writer{out} 16 | } 17 | 18 | func (w *Writer) writeBuffer(b []byte, err error) error { 19 | if err != nil { 20 | return err 21 | } 22 | n, err := w.out.Write(b) 23 | if err == nil && n != len(b) { 24 | return io.ErrShortWrite 25 | } 26 | return err 27 | } 28 | 29 | func (w *Writer) WriteFrame(b []byte) (err error) { 30 | err = w.writeBuffer(([]byte)(strconv.Itoa(len(b))), err) 31 | err = w.writeBuffer(lf, err) 32 | err = w.writeBuffer(b, err) 33 | return 34 | } 35 | -------------------------------------------------------------------------------- /api/v1/lib/extras/executor/eventrules/gen.go: -------------------------------------------------------------------------------- 1 | package eventrules 2 | 3 | //go:generate go run ../../gen/rules.go ../../gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/executor -type E:*executor.Event:&executor.Event{} 4 | 5 | //go:generate go run ../../gen/rule_handlers.go ../../gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/executor -import github.com/mesos/mesos-go/api/v1/lib/executor/events -type E:*executor.Event -type H:events.Handler -type HF:events.HandlerFunc -output handlers_generated.go 6 | 7 | //go:generate go run ../../gen/rule_metrics.go ../../gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/executor -type E:*executor.Event:&executor.Event{} -type ET:executor.Event_Type -output metrics_generated.go 8 | -------------------------------------------------------------------------------- /api/v1/lib/extras/scheduler/eventrules/gen.go: -------------------------------------------------------------------------------- 1 | package eventrules 2 | 3 | //go:generate go run ../../gen/rules.go ../../gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/scheduler -type E:*scheduler.Event:&scheduler.Event{} 4 | 5 | //go:generate go run ../../gen/rule_handlers.go ../../gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/scheduler -import github.com/mesos/mesos-go/api/v1/lib/scheduler/events -type E:*scheduler.Event -type H:events.Handler -type HF:events.HandlerFunc -output handlers_generated.go 6 | 7 | //go:generate go run ../../gen/rule_metrics.go ../../gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/scheduler -type E:*scheduler.Event:&scheduler.Event{} -type ET:scheduler.Event_Type -output metrics_generated.go 8 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/codegen/types_list.txt: -------------------------------------------------------------------------------- 1 | Interface,interface{},"something",nil,Inter 2 | Map,map[string]interface{},map[string]interface{}{"name":"Tyler"},nil,MSI 3 | ObjxMap,(Map),New(1),New(nil),ObjxMap 4 | Bool,bool,true,false,Bool 5 | String,string,"hello","",Str 6 | Int,int,1,0,Int 7 | Int8,int8,1,0,Int8 8 | Int16,int16,1,0,Int16 9 | Int32,int32,1,0,Int32 10 | Int64,int64,1,0,Int64 11 | Uint,uint,1,0,Uint 12 | Uint8,uint8,1,0,Uint8 13 | Uint16,uint16,1,0,Uint16 14 | Uint32,uint32,1,0,Uint32 15 | Uint64,uint64,1,0,Uint64 16 | Uintptr,uintptr,1,0,Uintptr 17 | Float32,float32,1,0,Float32 18 | Float64,float64,1,0,Float64 19 | Complex64,complex64,1,0,Complex64 20 | Complex128,complex128,1,0,Complex128 21 | -------------------------------------------------------------------------------- /api/doc.go: -------------------------------------------------------------------------------- 1 | // Package api presents two independently developed and maintained Mesos API implementations. 2 | // Clients should not consume this package directly. 3 | // 4 | // v0 5 | // 6 | // The "v0" subpackage has been tested for compatibility with the Mesos v0.2x release series and 7 | // utilizes the "unversioned" or "v0" libprocess-based API presented by Mesos. Support for the v0 8 | // API is on life-support and only critical bug fixes may be addressed. All current and future 9 | // development effort focuses on the v1 Mesos API. 10 | // 11 | // v1 12 | // 13 | // The "v1" subpackage is compatible with the Mesos v1.x release series and utilizes the v1 HTTP 14 | // API presented by Mesos. This is the recommended library to use for Mesos framework development. 15 | package api 16 | -------------------------------------------------------------------------------- /api/v1/docker/Makefile: -------------------------------------------------------------------------------- 1 | GOBINS = example-scheduler example-executor 2 | GOBINS_DIR = ../../../_output/ 3 | GOBINS_SRC = $(GOBINS:%=${GOBINS_DIR}%) 4 | 5 | .PHONY: all 6 | all: check prepare 7 | mkdir -p _output 8 | cp Dockerfile _output/ 9 | cp -p $(GOBINS_SRC) _output/ 10 | docker build -t $(DOCKER_IMAGE_TAG) _output 11 | 12 | .PHONY: info 13 | info: 14 | @echo GOBINS_SRC = $(GOBINS_SRC) 15 | 16 | .PHONY: check push 17 | push: 18 | docker push $(DOCKER_IMAGE_TAG) 19 | 20 | .PHONY: prepare 21 | prepare: $(GOBINS_SRC) 22 | 23 | .PHONY: clean 24 | clean: 25 | rm -rf _output 26 | 27 | .PHONY: check 28 | check: 29 | test -n "$(DOCKER_IMAGE_TAG)" || (echo "ERROR: DOCKER_IMAGE_TAG is undefined"; exit1) 30 | 31 | $(GOBINS_SRC): 32 | @test -x $@ || (echo "ERROR: missing binary dependency $@"; exit 1) 33 | -------------------------------------------------------------------------------- /api/v1/lib/extras/latch/latch_test.go: -------------------------------------------------------------------------------- 1 | package latch_test 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/mesos/mesos-go/api/v1/lib/extras/latch" 7 | ) 8 | 9 | func TestInterface(t *testing.T) { 10 | l := New() 11 | if l == nil { 12 | t.Fatalf("expected a valid latch, not nil") 13 | } 14 | if l.Closed() { 15 | t.Fatalf("expected new latch to be non-closed") 16 | } 17 | select { 18 | case <-l.Done(): 19 | t.Fatalf("Done chan unexpectedly closed for a new latch") 20 | default: 21 | } 22 | for i := 0; i < 2; i++ { 23 | l.Close() // multiple calls to close should not panic 24 | } 25 | if !l.Closed() { 26 | t.Fatalf("expected closed latch") 27 | } 28 | select { 29 | case <-l.Done(): 30 | default: 31 | t.Fatalf("Done chan unexpectedly non-closed for a closed latch") 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/pborman/uuid/json_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "encoding/json" 9 | "reflect" 10 | "testing" 11 | ) 12 | 13 | var testUUID = Parse("f47ac10b-58cc-0372-8567-0e02b2c3d479") 14 | 15 | func TestJSON(t *testing.T) { 16 | type S struct { 17 | ID1 UUID 18 | ID2 UUID 19 | } 20 | s1 := S{ID1: testUUID} 21 | data, err := json.Marshal(&s1) 22 | if err != nil { 23 | t.Fatal(err) 24 | } 25 | var s2 S 26 | if err := json.Unmarshal(data, &s2); err != nil { 27 | t.Fatal(err) 28 | } 29 | if !reflect.DeepEqual(&s1, &s2) { 30 | t.Errorf("got %#v, want %#v", s2, s1) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/v1/lib/resources/names.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "sort" 5 | 6 | "github.com/mesos/mesos-go/api/v1/lib" 7 | ) 8 | 9 | type ( 10 | Name string 11 | Names []Name 12 | ) 13 | 14 | const ( 15 | NameCPUs = Name("cpus") 16 | NameDisk = Name("disk") 17 | NameGPUs = Name("gpus") 18 | NameMem = Name("mem") 19 | NamePorts = Name("ports") 20 | ) 21 | 22 | // String implements fmt.Stringer 23 | func (n Name) String() string { return string(n) } 24 | func (n Name) Filter(r *mesos.Resource) bool { return r != nil && r.Name == string(n) } 25 | 26 | func (ns Names) Len() int { return len(ns) } 27 | func (ns Names) Less(i, j int) bool { return ns[i] < ns[j] } 28 | func (ns Names) Swap(i, j int) { ns[i], ns[j] = ns[j], ns[i] } 29 | 30 | func (ns Names) Sort() { sort.Stable(ns) } 31 | -------------------------------------------------------------------------------- /api/v1/cmd/vendor/golang.org/x/net/context/withtimeout_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package context_test 6 | 7 | import ( 8 | "fmt" 9 | "time" 10 | 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | func ExampleWithTimeout() { 15 | // Pass a context with a timeout to tell a blocking function that it 16 | // should abandon its work after the timeout elapses. 17 | ctx, _ := context.WithTimeout(context.Background(), 100*time.Millisecond) 18 | select { 19 | case <-time.After(200 * time.Millisecond): 20 | fmt.Println("overslept") 21 | case <-ctx.Done(): 22 | fmt.Println(ctx.Err()) // prints "context deadline exceeded" 23 | } 24 | // Output: 25 | // context deadline exceeded 26 | } 27 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/golang.org/x/net/context/withtimeout_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package context_test 6 | 7 | import ( 8 | "fmt" 9 | "time" 10 | 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | func ExampleWithTimeout() { 15 | // Pass a context with a timeout to tell a blocking function that it 16 | // should abandon its work after the timeout elapses. 17 | ctx, _ := context.WithTimeout(context.Background(), 100*time.Millisecond) 18 | select { 19 | case <-time.After(200 * time.Millisecond): 20 | fmt.Println("overslept") 21 | case <-ctx.Done(): 22 | fmt.Println(ctx.Err()) // prints "context deadline exceeded" 23 | } 24 | // Output: 25 | // context deadline exceeded 26 | } 27 | -------------------------------------------------------------------------------- /api/v0/mesosutil/node.go: -------------------------------------------------------------------------------- 1 | package mesosutil 2 | 3 | import ( 4 | "os" 5 | "os/exec" 6 | "strings" 7 | 8 | log "github.com/golang/glog" 9 | ) 10 | 11 | //TODO(jdef) copied from kubernetes/pkg/util/node.go 12 | func GetHostname(hostnameOverride string) string { 13 | hostname := hostnameOverride 14 | if hostname == "" { 15 | // Note: We use exec here instead of os.Hostname() because we 16 | // want the FQDN, and this is the easiest way to get it. 17 | fqdn, err := exec.Command("hostname", "-f").Output() 18 | if err != nil || len(fqdn) == 0 { 19 | log.Errorf("Couldn't determine hostname fqdn, failing back to hostname: %v", err) 20 | hostname, err = os.Hostname() 21 | if err != nil { 22 | log.Fatalf("Error getting hostname: %v", err) 23 | } 24 | } else { 25 | hostname = string(fqdn) 26 | } 27 | } 28 | return strings.TrimSpace(hostname) 29 | } 30 | -------------------------------------------------------------------------------- /api/v1/cmd/example-scheduler/app/env.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import ( 4 | "os" 5 | "strconv" 6 | "time" 7 | ) 8 | 9 | func env(key, defaultValue string) (value string) { 10 | if value = os.Getenv(key); value == "" { 11 | value = defaultValue 12 | } 13 | return 14 | } 15 | 16 | func envInt(key, defaultValue string) int { 17 | value, err := strconv.Atoi(env(key, defaultValue)) 18 | if err != nil { 19 | panic(err.Error()) 20 | } 21 | return value 22 | } 23 | 24 | func envDuration(key, defaultValue string) time.Duration { 25 | value, err := time.ParseDuration(env(key, defaultValue)) 26 | if err != nil { 27 | panic(err.Error()) 28 | } 29 | return value 30 | } 31 | 32 | func envFloat(key, defaultValue string) float64 { 33 | value, err := strconv.ParseFloat(env(key, defaultValue), 64) 34 | if err != nil { 35 | panic(err.Error()) 36 | } 37 | return value 38 | } 39 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/pborman/uuid/json.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import "errors" 8 | 9 | func (u UUID) MarshalJSON() ([]byte, error) { 10 | if len(u) == 0 { 11 | return []byte(`""`), nil 12 | } 13 | return []byte(`"` + u.String() + `"`), nil 14 | } 15 | 16 | func (u *UUID) UnmarshalJSON(data []byte) error { 17 | if len(data) == 0 || string(data) == `""` { 18 | return nil 19 | } 20 | if len(data) < 2 || data[0] != '"' || data[len(data)-1] != '"' { 21 | return errors.New("invalid UUID format") 22 | } 23 | data = data[1 : len(data)-1] 24 | uu := Parse(string(data)) 25 | if uu == nil { 26 | return errors.New("invalid UUID format") 27 | } 28 | *u = uu 29 | return nil 30 | } 31 | -------------------------------------------------------------------------------- /api/v1/lib/extras/executor/callrules/gen.go: -------------------------------------------------------------------------------- 1 | package callrules 2 | 3 | //go:generate go run ../../gen/rules.go ../../gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib -import github.com/mesos/mesos-go/api/v1/lib/executor -type E:*executor.Call:&executor.Call{} -type Z:mesos.Response:&mesos.ResponseWrapper{} 4 | 5 | //go:generate go run ../../gen/rule_callers.go ../../gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/executor -import github.com/mesos/mesos-go/api/v1/lib/executor/calls -type E:*executor.Call -type C:calls.Caller -type CF:calls.CallerFunc -output callers_generated.go 6 | 7 | //go:generate go run ../../gen/rule_metrics.go ../../gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib -import github.com/mesos/mesos-go/api/v1/lib/executor -type E:*executor.Call:&executor.Call{} -type ET:executor.Call_Type -type Z:mesos.Response:&mesos.ResponseWrapper{} -output metrics_generated.go 8 | -------------------------------------------------------------------------------- /api/v1/lib/encoding/json/json.go: -------------------------------------------------------------------------------- 1 | package json 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/mesos/mesos-go/api/v1/lib/encoding" 7 | "github.com/mesos/mesos-go/api/v1/lib/encoding/framing" 8 | ) 9 | 10 | // NewEncoder returns a new Encoder of Calls to JSON messages written to 11 | // the given io.Writer. 12 | func NewEncoder(s encoding.Sink) encoding.Encoder { 13 | w := s() 14 | return encoding.EncoderFunc(func(m encoding.Marshaler) error { 15 | b, err := json.Marshal(m) 16 | if err != nil { 17 | return err 18 | } 19 | return w.WriteFrame(b) 20 | }) 21 | } 22 | 23 | // NewDecoder returns a new Decoder of JSON messages read from the given source. 24 | func NewDecoder(s encoding.Source) encoding.Decoder { 25 | r := s() 26 | dec := framing.NewDecoder(r, json.Unmarshal) 27 | return encoding.DecoderFunc(func(u encoding.Unmarshaler) error { return dec.Decode(u) }) 28 | } 29 | -------------------------------------------------------------------------------- /api/v1/lib/extras/scheduler/callrules/gen.go: -------------------------------------------------------------------------------- 1 | package callrules 2 | 3 | //go:generate go run ../../gen/rules.go ../../gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib -import github.com/mesos/mesos-go/api/v1/lib/scheduler -type E:*scheduler.Call:&scheduler.Call{} -type Z:mesos.Response:&mesos.ResponseWrapper{} 4 | 5 | //go:generate go run ../../gen/rule_callers.go ../../gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib/scheduler -import github.com/mesos/mesos-go/api/v1/lib/scheduler/calls -type E:*scheduler.Call -type C:calls.Caller -type CF:calls.CallerFunc -output callers_generated.go 6 | 7 | //go:generate go run ../../gen/rule_metrics.go ../../gen/gen.go -import github.com/mesos/mesos-go/api/v1/lib -import github.com/mesos/mesos-go/api/v1/lib/scheduler -type E:*scheduler.Call:&scheduler.Call{} -type ET:scheduler.Call_Type -type Z:mesos.Response:&mesos.ResponseWrapper{} -output metrics_generated.go 8 | -------------------------------------------------------------------------------- /api/v0/detector/zoo/types.go: -------------------------------------------------------------------------------- 1 | package zoo 2 | 3 | import ( 4 | "github.com/samuel/go-zookeeper/zk" 5 | ) 6 | 7 | // Connector Interface to facade zk.Conn type 8 | // since github.com/samuel/go-zookeeper/zk does not provide an interface 9 | // for the zk.Conn object, this allows for mocking and easier testing. 10 | type Connector interface { 11 | Close() 12 | Children(string) ([]string, *zk.Stat, error) 13 | ChildrenW(string) ([]string, *zk.Stat, <-chan zk.Event, error) 14 | Get(string) ([]byte, *zk.Stat, error) 15 | } 16 | 17 | //Factory is an adapter to trap the creation of zk.Conn instances 18 | //since the official zk API does not expose an interface for zk.Conn. 19 | type Factory interface { 20 | create() (Connector, <-chan zk.Event, error) 21 | } 22 | 23 | type asFactory func() (Connector, <-chan zk.Event, error) 24 | 25 | func (f asFactory) create() (Connector, <-chan zk.Event, error) { 26 | return f() 27 | } 28 | -------------------------------------------------------------------------------- /api/v0/scheduler/handler.go: -------------------------------------------------------------------------------- 1 | package scheduler 2 | 3 | import ( 4 | "github.com/mesos/mesos-go/api/v0/auth/callback" 5 | mesos "github.com/mesos/mesos-go/api/v0/mesosproto" 6 | "github.com/mesos/mesos-go/api/v0/upid" 7 | ) 8 | 9 | type CredentialHandler struct { 10 | pid *upid.UPID // the process to authenticate against (master) 11 | client *upid.UPID // the process to be authenticated (slave / framework) 12 | credential *mesos.Credential 13 | } 14 | 15 | func (h *CredentialHandler) Handle(callbacks ...callback.Interface) error { 16 | for _, cb := range callbacks { 17 | switch cb := cb.(type) { 18 | case *callback.Name: 19 | cb.Set(h.credential.GetPrincipal()) 20 | case *callback.Password: 21 | cb.Set(([]byte)(h.credential.GetSecret())) 22 | case *callback.Interprocess: 23 | cb.Set(*(h.pid), *(h.client)) 24 | default: 25 | return &callback.Unsupported{Callback: cb} 26 | } 27 | } 28 | return nil 29 | } 30 | -------------------------------------------------------------------------------- /api/v0/messenger/testmessage/testmessage.proto: -------------------------------------------------------------------------------- 1 | package testmessage; 2 | 3 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 4 | 5 | option (gogoproto.gostring_all) = true; 6 | option (gogoproto.equal_all) = true; 7 | option (gogoproto.verbose_equal_all) = true; 8 | option (gogoproto.goproto_stringer_all) = false; 9 | option (gogoproto.stringer_all) = true; 10 | option (gogoproto.populate_all) = true; 11 | option (gogoproto.testgen_all) = false; 12 | option (gogoproto.benchgen_all) = false; 13 | option (gogoproto.marshaler_all) = true; 14 | option (gogoproto.sizer_all) = true; 15 | option (gogoproto.unmarshaler_all) = true; 16 | 17 | message SmallMessage { 18 | repeated string Values = 1; 19 | } 20 | 21 | message MediumMessage { 22 | repeated string Values = 1; 23 | } 24 | 25 | message BigMessage { 26 | repeated string Values = 1; 27 | } 28 | 29 | message LargeMessage { 30 | repeated string Values = 1; 31 | } 32 | -------------------------------------------------------------------------------- /api/v0/mesosproto/internal.proto: -------------------------------------------------------------------------------- 1 | package mesosproto; 2 | 3 | import "mesos.proto"; 4 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 5 | 6 | // For use with detector callbacks 7 | message InternalMasterChangeDetected { 8 | // will be present if there's a new master, otherwise nil 9 | optional MasterInfo master = 1; 10 | } 11 | 12 | message InternalTryAuthentication { 13 | // empty message, serves as a signal to the scheduler bindings 14 | } 15 | 16 | message InternalAuthenticationResult { 17 | // true only if the authentication process completed and login was successful 18 | required bool success = 1; 19 | // true if the authentication process completed, successfully or not 20 | required bool completed = 2; 21 | // master pid that this result pertains to 22 | required string pid = 3; 23 | } 24 | 25 | message InternalNetworkError { 26 | // master pid that this event pertains to 27 | required string pid = 1; 28 | // driver session UUID 29 | optional string session = 2; 30 | } 31 | -------------------------------------------------------------------------------- /api/v0/executor/testing.go: -------------------------------------------------------------------------------- 1 | package executor 2 | 3 | import ( 4 | "github.com/gogo/protobuf/proto" 5 | "github.com/mesos/mesos-go/api/v0/messenger" 6 | "github.com/mesos/mesos-go/api/v0/upid" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | type TestDriver struct { 11 | *MesosExecutorDriver 12 | } 13 | 14 | func (e *TestDriver) SetConnected(b bool) { 15 | e.guarded(func() { 16 | e.connected = b 17 | }) 18 | } 19 | 20 | func (e *TestDriver) SetMessenger(m messenger.Messenger) { 21 | e.messenger = m 22 | } 23 | 24 | func (e *TestDriver) Started() <-chan struct{} { 25 | return e.started 26 | } 27 | 28 | func (e *TestDriver) guarded(f func()) { 29 | e.lock.Lock() 30 | defer e.lock.Unlock() 31 | f() 32 | } 33 | 34 | func (e *TestDriver) Context() context.Context { 35 | return e.context() 36 | } 37 | 38 | func (e *TestDriver) StatusUpdateAcknowledgement(ctx context.Context, from *upid.UPID, msg proto.Message) { 39 | e.guarded(func() { 40 | e.statusUpdateAcknowledgement(ctx, from, msg) 41 | }) 42 | } 43 | -------------------------------------------------------------------------------- /api/v1/lib/scheduler/options.go: -------------------------------------------------------------------------------- 1 | package scheduler 2 | 3 | // A CallOpt is a functional option type for Calls. 4 | type CallOpt func(*Call) 5 | 6 | // With applies the given CallOpts to the receiving Call, returning it. 7 | func (c *Call) With(opts ...CallOpt) *Call { 8 | for _, opt := range opts { 9 | if opt != nil { 10 | opt(c) 11 | } 12 | } 13 | return c 14 | } 15 | 16 | // ReconcileOpt is a functional option type for Call_Reconcile 17 | type ReconcileOpt func(*Call_Reconcile) 18 | 19 | // With applies the given ReconcileOpt's to the receiving Call_Reconcile, returning it. 20 | func (r *Call_Reconcile) With(opts ...ReconcileOpt) *Call_Reconcile { 21 | for _, opt := range opts { 22 | if opt != nil { 23 | opt(r) 24 | } 25 | } 26 | return r 27 | } 28 | 29 | type CallOptions []CallOpt 30 | 31 | // Copy returns a cloned copy of CallOptions 32 | func (co CallOptions) Copy() CallOptions { 33 | if len(co) == 0 { 34 | return nil 35 | } 36 | x := make(CallOptions, len(co)) 37 | copy(x, co) 38 | return x 39 | } 40 | -------------------------------------------------------------------------------- /api/v1/lib/encoding/proto/encoding.go: -------------------------------------------------------------------------------- 1 | package proto 2 | 3 | import ( 4 | "github.com/gogo/protobuf/proto" 5 | "github.com/mesos/mesos-go/api/v1/lib/encoding" 6 | "github.com/mesos/mesos-go/api/v1/lib/encoding/framing" 7 | ) 8 | 9 | // NewEncoder returns a new Encoder of Calls to Protobuf messages written to 10 | // the given io.Writer. 11 | func NewEncoder(s encoding.Sink) encoding.Encoder { 12 | w := s() 13 | return encoding.EncoderFunc(func(m encoding.Marshaler) error { 14 | b, err := proto.Marshal(m.(proto.Message)) 15 | if err != nil { 16 | return err 17 | } 18 | return w.WriteFrame(b) 19 | }) 20 | } 21 | 22 | // NewDecoder returns a new Decoder of Protobuf messages read from the given Source. 23 | func NewDecoder(s encoding.Source) encoding.Decoder { 24 | r := s() 25 | var ( 26 | uf = func(b []byte, m interface{}) error { return proto.Unmarshal(b, m.(proto.Message)) } 27 | dec = framing.NewDecoder(r, uf) 28 | ) 29 | return encoding.DecoderFunc(func(u encoding.Unmarshaler) error { return dec.Decode(u) }) 30 | } 31 | -------------------------------------------------------------------------------- /api/v1/lib/extras/scheduler/callrules/helpers.go: -------------------------------------------------------------------------------- 1 | package callrules 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/mesos/mesos-go/api/v1/lib" 7 | "github.com/mesos/mesos-go/api/v1/lib/scheduler" 8 | ) 9 | 10 | // WithFrameworkID returns a Rule that injects a framework ID to outgoing calls, with the following exceptions: 11 | // - SUBSCRIBE calls are never modified (schedulers should explicitly construct such calls) 12 | // - calls are not modified when the detected framework ID is "" 13 | func WithFrameworkID(frameworkID func() string) Rule { 14 | return func(ctx context.Context, c *scheduler.Call, r mesos.Response, err error, ch Chain) (context.Context, *scheduler.Call, mesos.Response, error) { 15 | // never overwrite framework ID for subscribe calls; the scheduler must do that part 16 | if c.GetType() != scheduler.Call_SUBSCRIBE { 17 | if fid := frameworkID(); fid != "" { 18 | c2 := *c 19 | c2.FrameworkID = &mesos.FrameworkID{Value: fid} 20 | c = &c2 21 | } 22 | } 23 | return ch(ctx, c, r, err) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /api/v1/cmd/msh/msh.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Usage: msh {...command line args...} 4 | // 5 | // For example: 6 | // msh -master 10.2.0.5:5050 -- ls -laF /tmp 7 | // 8 | // TODO: -gpu=1 to enable GPU_RESOURCES caps and request 1 gpu 9 | // 10 | 11 | import ( 12 | "context" 13 | "flag" 14 | "log" 15 | "os" 16 | 17 | "github.com/mesos/mesos-go/api/v1/cmd/msh/app" 18 | ) 19 | 20 | func main() { 21 | conf := app.DefaultConfig() 22 | fs := flag.NewFlagSet(os.Args[0], flag.ExitOnError) 23 | conf.RegisterFlags(fs) 24 | fs.Parse(os.Args[1:]) 25 | 26 | conf.Command = fs.Args() 27 | if len(conf.Command) < 1 { // msh by itself prints usage 28 | fs.Usage() 29 | os.Exit(1) 30 | } 31 | 32 | msh := app.New(conf) 33 | if err := msh.Run(context.Background()); err != nil { 34 | if exitErr, ok := err.(app.ExitError); ok { 35 | if code := int(exitErr); code != 0 { 36 | log.Println(exitErr) 37 | os.Exit(code) 38 | } 39 | // else, code=0 indicates success, exit normally 40 | } else { 41 | log.Fatalf("%#v", err) 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/pborman/uuid/version4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | // Random returns a Random (Version 4) UUID or panics. 8 | // 9 | // The strength of the UUIDs is based on the strength of the crypto/rand 10 | // package. 11 | // 12 | // A note about uniqueness derived from from the UUID Wikipedia entry: 13 | // 14 | // Randomly generated UUIDs have 122 random bits. One's annual risk of being 15 | // hit by a meteorite is estimated to be one chance in 17 billion, that 16 | // means the probability is about 0.00000000006 (6 × 10−11), 17 | // equivalent to the odds of creating a few tens of trillions of UUIDs in a 18 | // year and having one duplicate. 19 | func NewRandom() UUID { 20 | uuid := make([]byte, 16) 21 | randomBits([]byte(uuid)) 22 | uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4 23 | uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10 24 | return uuid 25 | } 26 | -------------------------------------------------------------------------------- /api/v0/auth/sasl/mech/plugins.go: -------------------------------------------------------------------------------- 1 | package mech 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | 7 | log "github.com/golang/glog" 8 | ) 9 | 10 | var ( 11 | mechLock sync.Mutex 12 | supportedMechs = make(map[string]Factory) 13 | ) 14 | 15 | func Register(name string, f Factory) error { 16 | mechLock.Lock() 17 | defer mechLock.Unlock() 18 | 19 | if _, found := supportedMechs[name]; found { 20 | return fmt.Errorf("Mechanism registered twice: %s", name) 21 | } 22 | supportedMechs[name] = f 23 | log.V(1).Infof("Registered mechanism %s", name) 24 | return nil 25 | } 26 | 27 | func ListSupported() (list []string) { 28 | mechLock.Lock() 29 | defer mechLock.Unlock() 30 | 31 | for mechname := range supportedMechs { 32 | list = append(list, mechname) 33 | } 34 | return list 35 | } 36 | 37 | func SelectSupported(mechanisms []string) (selectedMech string, factory Factory) { 38 | mechLock.Lock() 39 | defer mechLock.Unlock() 40 | 41 | for _, m := range mechanisms { 42 | if f, ok := supportedMechs[m]; ok { 43 | selectedMech = m 44 | factory = f 45 | break 46 | } 47 | } 48 | return 49 | } 50 | -------------------------------------------------------------------------------- /api/v1/lib/encoding/codecs/codecs.go: -------------------------------------------------------------------------------- 1 | package codecs 2 | 3 | import ( 4 | "github.com/mesos/mesos-go/api/v1/lib/encoding" 5 | "github.com/mesos/mesos-go/api/v1/lib/encoding/json" 6 | "github.com/mesos/mesos-go/api/v1/lib/encoding/proto" 7 | ) 8 | 9 | const ( 10 | // MediaTypeProtobuf is the Protobuf serialization format media type. 11 | MediaTypeProtobuf = encoding.MediaType("application/x-protobuf") 12 | // MediaTypeJSON is the JSON serialiation format media type. 13 | MediaTypeJSON = encoding.MediaType("application/json") 14 | 15 | NameProtobuf = "protobuf" 16 | NameJSON = "json" 17 | ) 18 | 19 | // ByMediaType are pre-configured default Codecs, ready to use OOTB 20 | var ByMediaType = map[encoding.MediaType]encoding.Codec{ 21 | MediaTypeProtobuf: encoding.Codec{ 22 | Name: NameProtobuf, 23 | Type: MediaTypeProtobuf, 24 | NewEncoder: proto.NewEncoder, 25 | NewDecoder: proto.NewDecoder, 26 | }, 27 | MediaTypeJSON: encoding.Codec{ 28 | Name: NameJSON, 29 | Type: MediaTypeJSON, 30 | NewEncoder: json.NewEncoder, 31 | NewDecoder: json.NewDecoder, 32 | }, 33 | } 34 | -------------------------------------------------------------------------------- /api/v0/detector/doc.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | /* 20 | The detector package houses implementation of master detectors. 21 | The default implementation is the zookeeper master detector. 22 | It uses zookeeper to detect the lead Mesos master during startup/failover. 23 | */ 24 | package detector 25 | -------------------------------------------------------------------------------- /api/v1/lib/recordio/writer_test.go: -------------------------------------------------------------------------------- 1 | package recordio 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | "testing" 7 | ) 8 | 9 | type writerFunc func([]byte) (int, error) 10 | 11 | func (f writerFunc) Write(b []byte) (int, error) { return f(b) } 12 | 13 | func TestWriter(t *testing.T) { 14 | for i, tc := range []struct { 15 | frame []byte 16 | output []byte 17 | err error 18 | }{ 19 | {nil, ([]byte)("0\n"), nil}, 20 | {([]byte)("a"), ([]byte)("1\na"), nil}, 21 | {([]byte)("abc\n"), ([]byte)("4\nabc\n"), nil}, 22 | } { 23 | var buf bytes.Buffer 24 | w := NewWriter(&buf) 25 | err := w.WriteFrame(tc.frame) 26 | 27 | if err != tc.err { 28 | t.Fatalf("test case %d failed: expected error %v instead of %v", i, tc.err, err) 29 | } 30 | if b := buf.Bytes(); bytes.Compare(b, tc.output) != 0 { 31 | t.Fatalf("test case %d failed: expected bytes %q instead of %q", i, string(b), string(tc.output)) 32 | } 33 | } 34 | for i := 0; i < 5; i++ { 35 | w := NewWriter(writerFunc(func(_ []byte) (int, error) { return i, nil })) 36 | err := w.WriteFrame(([]byte)("james")) 37 | if err != io.ErrShortWrite { 38 | t.Fatalf("expected short write error with i=%d instead of %v", i, err) 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | # handle submodules ourselves 4 | git: 5 | submodules: false 6 | env: 7 | - PROTOBUF_VERSION=3.3.0 8 | go: 9 | # update validate-protobufs Makefile target once golang 1.11.x is no longer tested here 10 | - 1.9.x 11 | - 1.10.x 12 | - 1.11.x 13 | before_install: 14 | #these two lines help users who fork mesos-go. It's a noop when running from the mesos organization 15 | - RepoName=`basename $PWD`; SrcDir=`dirname $PWD`; DestDir="`dirname $SrcDir`/mesos" 16 | - if [[ "$SrcDir" != "$DestDir" ]]; then mv "$SrcDir" "$DestDir"; cd ../../mesos/$RepoName; export TRAVIS_BUILD_DIR=`dirname $TRAVIS_BUILD_DIR`/$RepoName; fi 17 | - go get github.com/mattn/goveralls 18 | - go get github.com/kardianos/govendor 19 | - make sync 20 | - api/v1/vendor/github.com/gogo/protobuf/install-protobuf.sh 21 | # re-generate protobuf and json code, check that there are no differences w/ respect to what's been checked in 22 | # ONLY for golang1.11.x; generated protobufs are not guaranteed to be consistent across golang versions 23 | - make validate-protobufs 24 | install: 25 | - make test install 26 | script: 27 | - if [[ "$TRAVIS_EVENT_TYPE" = "pull_request" ]] || [[ "$TRAVIS_BRANCH" = "master" ]]; then make coveralls; fi 28 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/LICENSE.md: -------------------------------------------------------------------------------- 1 | objx - by Mat Ryer and Tyler Bunnell 2 | 3 | The MIT License (MIT) 4 | 5 | Copyright (c) 2014 Stretchr, Inc. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /api/v1/lib/encoding/framing/decoder.go: -------------------------------------------------------------------------------- 1 | package framing 2 | 3 | type ( 4 | // UnmarshalFunc translates bytes to objects 5 | UnmarshalFunc func([]byte, interface{}) error 6 | 7 | // Decoder reads and decodes Protobuf messages from an io.Reader. 8 | Decoder interface { 9 | // Decode reads the next encoded message from its input and stores it 10 | // in the value pointed to by m. If m isn't a proto.Message, Decode will panic. 11 | Decode(interface{}) error 12 | } 13 | 14 | // DecoderFunc is the functional adaptation of Decoder 15 | DecoderFunc func(interface{}) error 16 | ) 17 | 18 | func (f DecoderFunc) Decode(m interface{}) error { return f(m) } 19 | 20 | var _ = Decoder(DecoderFunc(nil)) 21 | 22 | // NewDecoder returns a new Decoder that reads from the given frame Reader. 23 | func NewDecoder(r Reader, uf UnmarshalFunc) DecoderFunc { 24 | return func(m interface{}) error { 25 | // Note: the buf returned by ReadFrame will change over time, it can't be sub-sliced 26 | // and then those sub-slices retained. Examination of generated proto code seems to indicate 27 | // that byte buffers are copied vs. referenced by sub-slice (gogo protoc). 28 | frame, err := r.ReadFrame() 29 | if err != nil { 30 | return err 31 | } 32 | return uf(frame, m) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /api/v1/lib/fixedpoint.go: -------------------------------------------------------------------------------- 1 | package mesos 2 | 3 | // fixed point scalar math from mesos:src/common/values.cpp 4 | // -- 5 | // We manipulate scalar values by converting them from floating point to a 6 | // fixed point representation, doing a calculation, and then converting 7 | // the result back to floating point. We deliberately only preserve three 8 | // decimal digits of precision in the fixed point representation. This 9 | // ensures that client applications see predictable numerical behavior, at 10 | // the expense of sacrificing some precision. 11 | 12 | import "math" 13 | 14 | func convertToFloat64(f int64) float64 { 15 | // NOTE: We do the conversion from fixed point via integer division 16 | // and then modulus, rather than a single floating point division. 17 | // This ensures that we only apply floating point division to inputs 18 | // in the range [0,999], which is easier to check for correctness. 19 | var ( 20 | quotient = float64(f / 1000) 21 | remainder = float64(f%1000) / 1000.0 22 | ) 23 | return quotient + remainder 24 | } 25 | 26 | func convertToFixed64(f float64) int64 { 27 | return round64(f * 1000) 28 | } 29 | 30 | func round64(f float64) int64 { 31 | if math.Abs(f) < 0.5 { 32 | return 0 33 | } 34 | return int64(f + math.Copysign(0.5, f)) 35 | } 36 | -------------------------------------------------------------------------------- /api/v0/messenger/testmessage/generator.go: -------------------------------------------------------------------------------- 1 | package testmessage 2 | 3 | import ( 4 | "math/rand" 5 | ) 6 | 7 | func generateRandomString(length int) string { 8 | b := make([]byte, length) 9 | for i := range b { 10 | b[i] = byte(rand.Int()) 11 | } 12 | return string(b) 13 | } 14 | 15 | // GenerateSmallMessage generates a small size message. 16 | func GenerateSmallMessage() *SmallMessage { 17 | v := make([]string, 3) 18 | for i := range v { 19 | v[i] = generateRandomString(5) 20 | } 21 | return &SmallMessage{Values: v} 22 | } 23 | 24 | // GenerateMediumMessage generates a medium size message. 25 | func GenerateMediumMessage() *MediumMessage { 26 | v := make([]string, 10) 27 | for i := range v { 28 | v[i] = generateRandomString(10) 29 | } 30 | return &MediumMessage{Values: v} 31 | } 32 | 33 | // GenerateBigMessage generates a big size message. 34 | func GenerateBigMessage() *BigMessage { 35 | v := make([]string, 20) 36 | for i := range v { 37 | v[i] = generateRandomString(20) 38 | } 39 | return &BigMessage{Values: v} 40 | } 41 | 42 | // GenerateLargeMessage generates a large size message. 43 | func GenerateLargeMessage() *LargeMessage { 44 | v := make([]string, 30) 45 | for i := range v { 46 | v[i] = generateRandomString(30) 47 | } 48 | return &LargeMessage{Values: v} 49 | } 50 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/simple_example_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestSimpleExample(t *testing.T) { 9 | 10 | // build a map from a JSON object 11 | o := MustFromJSON(`{"name":"Mat","foods":["indian","chinese"], "location":{"county":"hobbiton","city":"the shire"}}`) 12 | 13 | // Map can be used as a straight map[string]interface{} 14 | assert.Equal(t, o["name"], "Mat") 15 | 16 | // Get an Value object 17 | v := o.Get("name") 18 | assert.Equal(t, v, &Value{data: "Mat"}) 19 | 20 | // Test the contained value 21 | assert.False(t, v.IsInt()) 22 | assert.False(t, v.IsBool()) 23 | assert.True(t, v.IsStr()) 24 | 25 | // Get the contained value 26 | assert.Equal(t, v.Str(), "Mat") 27 | 28 | // Get a default value if the contained value is not of the expected type or does not exist 29 | assert.Equal(t, 1, v.Int(1)) 30 | 31 | // Get a value by using array notation 32 | assert.Equal(t, "indian", o.Get("foods[0]").Data()) 33 | 34 | // Set a value by using array notation 35 | o.Set("foods[0]", "italian") 36 | assert.Equal(t, "italian", o.Get("foods[0]").Str()) 37 | 38 | // Get a value by using dot notation 39 | assert.Equal(t, "hobbiton", o.Get("location.county").Str()) 40 | 41 | } 42 | -------------------------------------------------------------------------------- /api/v0/auth/sasl/mech/interface.go: -------------------------------------------------------------------------------- 1 | package mech 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/mesos/mesos-go/api/v0/auth/callback" 7 | ) 8 | 9 | var ( 10 | IllegalStateErr = errors.New("illegal mechanism state") 11 | ) 12 | 13 | type Interface interface { 14 | Handler() callback.Handler 15 | Discard() // clean up resources or sensitive information; idempotent 16 | } 17 | 18 | // return a mechanism and it's initialization step (may be a noop that returns 19 | // a nil data blob and handle to the first "real" challenge step). 20 | type Factory func(h callback.Handler) (Interface, StepFunc, error) 21 | 22 | // StepFunc implementations should never return a nil StepFunc result. This 23 | // helps keep the logic in the SASL authticatee simpler: step functions are 24 | // never nil. Mechanisms that end up an error state (for example, some decoding 25 | // logic fails...) should return a StepFunc that represents an error state. 26 | // Some mechanisms may be able to recover from such. 27 | type StepFunc func(m Interface, data []byte) (StepFunc, []byte, error) 28 | 29 | // reflects an unrecoverable, illegal mechanism state; always returns IllegalState 30 | // as the next step along with an IllegalStateErr 31 | func IllegalState(m Interface, data []byte) (StepFunc, []byte, error) { 32 | return IllegalState, nil, IllegalStateErr 33 | } 34 | -------------------------------------------------------------------------------- /api/v1/lib/scheduler/calls/calls_generated.go: -------------------------------------------------------------------------------- 1 | package calls 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/scheduler -type C:*scheduler.Call 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | 9 | "github.com/mesos/mesos-go/api/v1/lib" 10 | 11 | "github.com/mesos/mesos-go/api/v1/lib/scheduler" 12 | ) 13 | 14 | type ( 15 | // Caller is the public interface this framework scheduler's should consume 16 | Caller interface { 17 | // Call issues a call to Mesos and properly manages call-specific HTTP response headers & data. 18 | Call(context.Context, *scheduler.Call) (mesos.Response, error) 19 | } 20 | 21 | // CallerFunc is the functional adaptation of the Caller interface 22 | CallerFunc func(context.Context, *scheduler.Call) (mesos.Response, error) 23 | ) 24 | 25 | // Call implements the Caller interface for CallerFunc 26 | func (f CallerFunc) Call(ctx context.Context, c *scheduler.Call) (mesos.Response, error) { 27 | return f(ctx, c) 28 | } 29 | 30 | // CallNoData is a convenience func that executes the given Call using the provided Caller 31 | // and always drops the response data. 32 | func CallNoData(ctx context.Context, caller Caller, call *scheduler.Call) error { 33 | resp, err := caller.Call(ctx, call) 34 | if resp != nil { 35 | resp.Close() 36 | } 37 | return err 38 | } 39 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/auth_basic.go: -------------------------------------------------------------------------------- 1 | package httpcli 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | // roundTripperFunc is the functional adaptation of http.RoundTripper 8 | type roundTripperFunc func(*http.Request) (*http.Response, error) 9 | 10 | // RoundTrip implements RoundTripper for roundTripperFunc 11 | func (f roundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error) { return f(req) } 12 | 13 | // BasicAuth generates a functional config option that sets HTTP Basic authentication for a Client 14 | func BasicAuth(username, passwd string) ConfigOpt { 15 | // TODO(jdef) this could be more efficient. according to the stdlib we're not supposed to 16 | // mutate the original Request, so we copy here (including headers). another approach would 17 | // be to generate a functional RequestOpt that adds the right header. 18 | return WrapRoundTripper(func(rt http.RoundTripper) http.RoundTripper { 19 | return roundTripperFunc(func(req *http.Request) (*http.Response, error) { 20 | var h http.Header 21 | if req.Header != nil { 22 | h = make(http.Header, len(req.Header)) 23 | for k, v := range req.Header { 24 | h[k] = append(make([]string, 0, len(v)), v...) 25 | } 26 | } 27 | clonedReq := *req 28 | clonedReq.Header = h 29 | clonedReq.SetBasicAuth(username, passwd) 30 | return rt.RoundTrip(&clonedReq) 31 | }) 32 | }) 33 | } 34 | -------------------------------------------------------------------------------- /api/v1/lib/executor/calls/calls_caller_generated.go: -------------------------------------------------------------------------------- 1 | package calls 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/executor -type C:*executor.Call -output calls_caller_generated.go 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | 9 | "github.com/mesos/mesos-go/api/v1/lib" 10 | 11 | "github.com/mesos/mesos-go/api/v1/lib/executor" 12 | ) 13 | 14 | type ( 15 | // Caller is the public interface this framework scheduler's should consume 16 | Caller interface { 17 | // Call issues a call to Mesos and properly manages call-specific HTTP response headers & data. 18 | Call(context.Context, *executor.Call) (mesos.Response, error) 19 | } 20 | 21 | // CallerFunc is the functional adaptation of the Caller interface 22 | CallerFunc func(context.Context, *executor.Call) (mesos.Response, error) 23 | ) 24 | 25 | // Call implements the Caller interface for CallerFunc 26 | func (f CallerFunc) Call(ctx context.Context, c *executor.Call) (mesos.Response, error) { 27 | return f(ctx, c) 28 | } 29 | 30 | // CallNoData is a convenience func that executes the given Call using the provided Caller 31 | // and always drops the response data. 32 | func CallNoData(ctx context.Context, caller Caller, call *executor.Call) error { 33 | resp, err := caller.Call(ctx, call) 34 | if resp != nil { 35 | resp.Close() 36 | } 37 | return err 38 | } 39 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/pborman/uuid/version1.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "encoding/binary" 9 | ) 10 | 11 | // NewUUID returns a Version 1 UUID based on the current NodeID and clock 12 | // sequence, and the current time. If the NodeID has not been set by SetNodeID 13 | // or SetNodeInterface then it will be set automatically. If the NodeID cannot 14 | // be set NewUUID returns nil. If clock sequence has not been set by 15 | // SetClockSequence then it will be set automatically. If GetTime fails to 16 | // return the current NewUUID returns nil. 17 | func NewUUID() UUID { 18 | if nodeID == nil { 19 | SetNodeInterface("") 20 | } 21 | 22 | now, seq, err := GetTime() 23 | if err != nil { 24 | return nil 25 | } 26 | 27 | uuid := make([]byte, 16) 28 | 29 | time_low := uint32(now & 0xffffffff) 30 | time_mid := uint16((now >> 32) & 0xffff) 31 | time_hi := uint16((now >> 48) & 0x0fff) 32 | time_hi |= 0x1000 // Version 1 33 | 34 | binary.BigEndian.PutUint32(uuid[0:], time_low) 35 | binary.BigEndian.PutUint16(uuid[4:], time_mid) 36 | binary.BigEndian.PutUint16(uuid[6:], time_hi) 37 | binary.BigEndian.PutUint16(uuid[8:], seq) 38 | copy(uuid[10:], nodeID) 39 | 40 | return uuid 41 | } 42 | -------------------------------------------------------------------------------- /api/v1/lib/extras/latch/latch.go: -------------------------------------------------------------------------------- 1 | package latch 2 | 3 | import "sync/atomic" 4 | 5 | // Interface funcs are safe to invoke concurrently. 6 | type Interface interface { 7 | // Done returns a chan that blocks until Close is called. It never returns data. 8 | Done() <-chan struct{} 9 | // Close closes the latch; all future calls to Closed return true. Safe to invoke multiple times. 10 | Close() 11 | // Closed returns false while the latch is "open" and true after it has been closed via Close. 12 | Closed() bool 13 | } 14 | 15 | type L struct { 16 | value int32 17 | line chan struct{} 18 | } 19 | 20 | // New returns a new "open" latch such that Closed returns false until Close is invoked. 21 | func New() Interface { 22 | return new(L).Reset() 23 | } 24 | 25 | func (l *L) Done() <-chan struct{} { return l.line } 26 | 27 | // Close may panic for an uninitialized L 28 | func (l *L) Close() { 29 | if atomic.AddInt32(&l.value, 1) == 1 { 30 | close(l.line) 31 | } 32 | <-l.line // concurrent calls to Close block until the latch is actually closed 33 | } 34 | 35 | func (l *L) Closed() (result bool) { 36 | select { 37 | case <-l.line: 38 | result = true 39 | default: 40 | } 41 | return 42 | } 43 | 44 | // Reset clears the state of the latch, not safe to execute concurrently with other L methods. 45 | func (l *L) Reset() *L { 46 | l.line, l.value = make(chan struct{}), 0 47 | return l 48 | } 49 | -------------------------------------------------------------------------------- /api/v0/upid/upid_test.go: -------------------------------------------------------------------------------- 1 | package upid 2 | 3 | import ( 4 | "testing" 5 | "testing/quick" 6 | 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | func TestUPIDParse(t *testing.T) { 11 | u, err := Parse("mesos@foo:bar") 12 | assert.Nil(t, u) 13 | assert.Error(t, err) 14 | 15 | u, err = Parse("mesoslocalhost5050") 16 | assert.Nil(t, u) 17 | assert.Error(t, err) 18 | 19 | u, err = Parse("mesos@localhost") 20 | assert.Nil(t, u) 21 | assert.Error(t, err) 22 | 23 | assert.Nil(t, quick.Check(func(s string) bool { 24 | u, err := Parse(s) 25 | return u == nil && err != nil 26 | }, &quick.Config{MaxCount: 100000})) 27 | } 28 | 29 | func TestUPIDString(t *testing.T) { 30 | u, err := Parse("mesos@localhost:5050") 31 | assert.NotNil(t, u) 32 | assert.NoError(t, err) 33 | assert.Equal(t, "mesos@localhost:5050", u.String()) 34 | } 35 | 36 | func TestUPIDEqual(t *testing.T) { 37 | u1, err := Parse("mesos@localhost:5050") 38 | u2, err := Parse("mesos@localhost:5050") 39 | u3, err := Parse("mesos1@localhost:5050") 40 | u4, err := Parse("mesos@mesos.com:5050") 41 | u5, err := Parse("mesos@localhost:5051") 42 | assert.NoError(t, err) 43 | 44 | assert.True(t, u1.Equal(u2)) 45 | assert.False(t, u1.Equal(u3)) 46 | assert.False(t, u1.Equal(u4)) 47 | assert.False(t, u1.Equal(u5)) 48 | assert.False(t, u1.Equal(nil)) 49 | assert.False(t, (*UPID)(nil).Equal(u5)) 50 | assert.True(t, (*UPID)(nil).Equal(nil)) 51 | } 52 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/opts.go: -------------------------------------------------------------------------------- 1 | package httpcli 2 | 3 | type ( 4 | // Opt defines a functional option for the HTTP client type. A functional option 5 | // must return an Opt that acts as an "undo" if applied to the same Client. 6 | Opt func(*Client) Opt 7 | // Opts represents a series of functional options 8 | Opts []Opt 9 | ) 10 | 11 | // Apply is a nil-safe application of an Opt: if the receiver is nil then this func 12 | // simply returns nil, otherwise it returns the result invoking the receiving Opt 13 | // with the given Client. 14 | func (o Opt) Apply(c *Client) (result Opt) { 15 | if o != nil { 16 | result = o(c) 17 | } 18 | return 19 | } 20 | 21 | // Merged generates a single Opt that applies all the functional options, in-order 22 | func (opts Opts) Merged() Opt { 23 | if len(opts) == 0 { 24 | return nil 25 | } 26 | return func(c *Client) Opt { 27 | var ( 28 | size = len(opts) 29 | undo = make(Opts, size) 30 | ) 31 | size-- // make this a zero-based offset 32 | for i, opt := range opts { 33 | if opt != nil { 34 | undo[size-i] = opt(c) 35 | } 36 | } 37 | return undo.Merged() 38 | } 39 | } 40 | 41 | // And combines two functional options into a single Opt 42 | func (o Opt) And(other Opt) Opt { 43 | if o == nil { 44 | if other == nil { 45 | return nil 46 | } 47 | return other 48 | } 49 | if other == nil { 50 | return o 51 | } 52 | return Opts{o, other}.Merged() 53 | } 54 | -------------------------------------------------------------------------------- /api/v0/README.md: -------------------------------------------------------------------------------- 1 | # Go bindings for Apache Mesos 2 | 3 | Very early version of a pure Go language bindings for Apache Mesos. As with other pure implementation, mesos-go uses the HTTP wire protocol to communicate directly with a running Mesos master and its slave instances. One of the objectives of this project is to provide an idiomatic Go API that makes it super easy to create Mesos frameworks using Go. 4 | 5 | ## Status 6 | The Mesos v0 API version of the bindings are considered **alpha** and won't 7 | see any major development besides critical compatibility and bug fixes. 8 | 9 | New projects should use the Mesos v1 API bindings, located in `api/v1`. 10 | 11 | ### Features 12 | - The SchedulerDriver API implemented 13 | - The ExecutorDriver API implemented 14 | - Stable API (based on the core Mesos code) 15 | - Plenty of unit and integrative of tests 16 | - Modular design for easy readability/extensibility 17 | - Example programs on how to use the API 18 | - Leading master detection 19 | - Authentication via SASL/CRAM-MD5 20 | 21 | ### Pre-Requisites 22 | - Go 1.3 or higher 23 | - A standard and working Go workspace setup 24 | - Apache Mesos 0.19 or newer 25 | 26 | ## Installing 27 | Users of this library are encouraged to vendor it. API stability isn't guaranteed at this stage. 28 | ```shell 29 | $ go get github.com/mesos/mesos-go 30 | ``` 31 | 32 | ## Testing 33 | ```shell 34 | $ (cd $GOPATH/src/github.com/mesos/mesos-go/api/v0; go test -race ./...) 35 | ``` 36 | -------------------------------------------------------------------------------- /api/v1/lib/encoding/proto/encoding_test.go: -------------------------------------------------------------------------------- 1 | package proto_test 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | 7 | "github.com/mesos/mesos-go/api/v1/lib" 8 | "github.com/mesos/mesos-go/api/v1/lib/encoding" 9 | . "github.com/mesos/mesos-go/api/v1/lib/encoding/proto" 10 | ) 11 | 12 | type FakeMessage string 13 | 14 | func (f *FakeMessage) Marshal() ([]byte, error) { return ([]byte)(*f), nil } 15 | func (f *FakeMessage) MarshalJSON() ([]byte, error) { return nil, nil } 16 | 17 | func TestEncoder(t *testing.T) { 18 | // write a proto message, validate that we're actually marshaling proto 19 | buf := bytes.Buffer{} 20 | enc := NewEncoder(encoding.SinkWriter(&buf)) 21 | err := enc.Encode(&mesos.FrameworkID{Value: "hello"}) 22 | 23 | if err != nil { 24 | t.Fatal(err) 25 | } 26 | 27 | data := string(buf.Bytes()) 28 | if data != "\n\x05hello" { 29 | // \n == 00001 010 == {field-id} {tag-type} 30 | // \x05 == length of the string 31 | t.Fatalf("expected `hello` instead of %q", data) 32 | } 33 | 34 | // write a non-proto message, verify panic 35 | caughtPanic := false 36 | func() { 37 | defer func() { 38 | if x := recover(); x != nil { 39 | caughtPanic = true 40 | } 41 | }() 42 | m := FakeMessage("hello") 43 | enc.Encode(&m) 44 | t.Fatal("expected panic, but Encode completed normally") 45 | }() 46 | if !caughtPanic { 47 | t.Fatal("Encode failed to complete normally, but we didn't see a panic? should never happen") 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /api/v1/lib/extras/gen/callers.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import ( 6 | "os" 7 | "text/template" 8 | ) 9 | 10 | func main() { 11 | Run(handlersTemplate, nil, os.Args...) 12 | } 13 | 14 | var handlersTemplate = template.Must(template.New("").Parse(`package {{.Package}} 15 | 16 | // go generate {{.Args}} 17 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/mesos/mesos-go/api/v1/lib" 23 | {{range .Imports}} 24 | {{ printf "%q" . -}} 25 | {{end}} 26 | ) 27 | 28 | {{.RequireType "C" -}} 29 | type ( 30 | // Caller is the public interface this framework scheduler's should consume 31 | Caller interface { 32 | // Call issues a call to Mesos and properly manages call-specific HTTP response headers & data. 33 | Call(context.Context, {{.Type "C"}}) (mesos.Response, error) 34 | } 35 | 36 | // CallerFunc is the functional adaptation of the Caller interface 37 | CallerFunc func(context.Context, {{.Type "C"}}) (mesos.Response, error) 38 | ) 39 | 40 | // Call implements the Caller interface for CallerFunc 41 | func (f CallerFunc) Call(ctx context.Context, c {{.Type "C"}}) (mesos.Response, error) { 42 | return f(ctx, c) 43 | } 44 | 45 | // CallNoData is a convenience func that executes the given Call using the provided Caller 46 | // and always drops the response data. 47 | func CallNoData(ctx context.Context, caller Caller, call {{.Type "C"}}) error { 48 | resp, err := caller.Call(ctx, call) 49 | if resp != nil { 50 | resp.Close() 51 | } 52 | return err 53 | } 54 | `)) 55 | -------------------------------------------------------------------------------- /api/v0/examples/zkdetect/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | 7 | log "github.com/golang/glog" 8 | "github.com/mesos/mesos-go/api/v0/detector" 9 | _ "github.com/mesos/mesos-go/api/v0/detector/zoo" 10 | mesos "github.com/mesos/mesos-go/api/v0/mesosproto" 11 | ) 12 | 13 | type zkListener struct{} 14 | 15 | func (l *zkListener) OnMasterChanged(info *mesos.MasterInfo) { 16 | if info == nil { 17 | log.Infoln("master lost") 18 | } else { 19 | log.Infof("master changed: %s", masterString(info)) 20 | } 21 | } 22 | 23 | func (l *zkListener) UpdatedMasters(all []*mesos.MasterInfo) { 24 | for i, info := range all { 25 | log.Infof("master (%d): %s", i, masterString(info)) 26 | } 27 | } 28 | 29 | func masterString(info *mesos.MasterInfo) string { 30 | return fmt.Sprintf("Id %v Ip %v Hostname %v Port %v Version %v Pid %v", 31 | info.GetId(), info.GetIp(), info.GetHostname(), info.GetPort(), info.GetVersion(), info.GetPid()) 32 | } 33 | 34 | func main() { 35 | masters := flag.String("masters", "zk://localhost:2181/mesos", "ZK Mesos masters URI") 36 | flag.Parse() 37 | 38 | log.Infof("creating ZK detector for %q", *masters) 39 | 40 | m, err := detector.New(*masters) 41 | if err != nil { 42 | log.Fatalf("failed to create ZK listener for Mesos masters: %v", err) 43 | } 44 | 45 | log.Info("created ZK detector") 46 | err = m.Detect(&zkListener{}) 47 | if err != nil { 48 | log.Fatalf("failed to register ZK listener: %v", err) 49 | } 50 | 51 | log.Info("registered ZK listener") 52 | select {} // never stop 53 | } 54 | -------------------------------------------------------------------------------- /api/v0/auth/sasl/context.go: -------------------------------------------------------------------------------- 1 | package sasl 2 | 3 | import ( 4 | "net" 5 | "strconv" 6 | 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // unexported to prevent collisions with context keys defined in 11 | // other packages. 12 | type _key int 13 | 14 | // If this package defined other context keys, they would have 15 | // different integer values. 16 | const ( 17 | statusKey _key = iota 18 | bindingAddressKey // bind address for login-related network ops 19 | bindingPortKey // port to bind auth listener if a specific port is needed 20 | ) 21 | 22 | func withStatus(ctx context.Context, s statusType) context.Context { 23 | return context.WithValue(ctx, statusKey, s) 24 | } 25 | 26 | func statusFrom(ctx context.Context) statusType { 27 | s, ok := ctx.Value(statusKey).(statusType) 28 | if !ok { 29 | panic("missing status in context") 30 | } 31 | return s 32 | } 33 | 34 | func WithBindingAddress(ctx context.Context, address net.IP) context.Context { 35 | return context.WithValue(ctx, bindingAddressKey, address) 36 | } 37 | 38 | func BindingAddressFrom(ctx context.Context) net.IP { 39 | obj := ctx.Value(bindingAddressKey) 40 | if addr, ok := obj.(net.IP); ok { 41 | return addr 42 | } else { 43 | return nil 44 | } 45 | } 46 | 47 | func WithBindingPort(ctx context.Context, port uint16) context.Context { 48 | return context.WithValue(ctx, bindingPortKey, port) 49 | } 50 | 51 | func BindingPortFrom(ctx context.Context) string { 52 | if port, ok := ctx.Value(bindingPortKey).(uint16); ok { 53 | return strconv.Itoa(int(port)) 54 | } 55 | return "0" 56 | } 57 | -------------------------------------------------------------------------------- /api/v0/scheduler/mock/scheduler.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | log "github.com/golang/glog" 5 | mesos "github.com/mesos/mesos-go/api/v0/mesosproto" 6 | "github.com/stretchr/testify/mock" 7 | 8 | . "github.com/mesos/mesos-go/api/v0/scheduler" 9 | ) 10 | 11 | type MockScheduler struct { 12 | mock.Mock 13 | } 14 | 15 | func New() *MockScheduler { 16 | return &MockScheduler{} 17 | } 18 | 19 | func (sched *MockScheduler) Registered(SchedulerDriver, *mesos.FrameworkID, *mesos.MasterInfo) { 20 | sched.Called() 21 | } 22 | 23 | func (sched *MockScheduler) Reregistered(SchedulerDriver, *mesos.MasterInfo) { 24 | sched.Called() 25 | } 26 | 27 | func (sched *MockScheduler) Disconnected(SchedulerDriver) { 28 | sched.Called() 29 | } 30 | 31 | func (sched *MockScheduler) ResourceOffers(SchedulerDriver, []*mesos.Offer) { 32 | sched.Called() 33 | } 34 | 35 | func (sched *MockScheduler) OfferRescinded(SchedulerDriver, *mesos.OfferID) { 36 | sched.Called() 37 | } 38 | 39 | func (sched *MockScheduler) StatusUpdate(SchedulerDriver, *mesos.TaskStatus) { 40 | sched.Called() 41 | } 42 | 43 | func (sched *MockScheduler) FrameworkMessage(SchedulerDriver, *mesos.ExecutorID, *mesos.SlaveID, string) { 44 | sched.Called() 45 | } 46 | 47 | func (sched *MockScheduler) SlaveLost(SchedulerDriver, *mesos.SlaveID) { 48 | sched.Called() 49 | } 50 | 51 | func (sched *MockScheduler) ExecutorLost(SchedulerDriver, *mesos.ExecutorID, *mesos.SlaveID, int) { 52 | sched.Called() 53 | } 54 | 55 | func (sched *MockScheduler) Error(d SchedulerDriver, msg string) { 56 | log.Error(msg) 57 | sched.Called() 58 | } 59 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/golang/glog/README: -------------------------------------------------------------------------------- 1 | glog 2 | ==== 3 | 4 | Leveled execution logs for Go. 5 | 6 | This is an efficient pure Go implementation of leveled logs in the 7 | manner of the open source C++ package 8 | http://code.google.com/p/google-glog 9 | 10 | By binding methods to booleans it is possible to use the log package 11 | without paying the expense of evaluating the arguments to the log. 12 | Through the -vmodule flag, the package also provides fine-grained 13 | control over logging at the file level. 14 | 15 | The comment from glog.go introduces the ideas: 16 | 17 | Package glog implements logging analogous to the Google-internal 18 | C++ INFO/ERROR/V setup. It provides functions Info, Warning, 19 | Error, Fatal, plus formatting variants such as Infof. It 20 | also provides V-style logging controlled by the -v and 21 | -vmodule=file=2 flags. 22 | 23 | Basic examples: 24 | 25 | glog.Info("Prepare to repel boarders") 26 | 27 | glog.Fatalf("Initialization failed: %s", err) 28 | 29 | See the documentation for the V function for an explanation 30 | of these examples: 31 | 32 | if glog.V(2) { 33 | glog.Info("Starting transaction...") 34 | } 35 | 36 | glog.V(2).Infoln("Processed", nItems, "elements") 37 | 38 | 39 | The repository contains an open source version of the log package 40 | used inside Google. The master copy of the source lives inside 41 | Google, not here. The code in this repo is for export only and is not itself 42 | under development. Feature requests will be ignored. 43 | 44 | Send bug reports to golang-nuts@googlegroups.com. 45 | -------------------------------------------------------------------------------- /api/v1/lib/scheduler/calls/calls_test.go: -------------------------------------------------------------------------------- 1 | package calls_test 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "testing" 7 | 8 | "github.com/mesos/mesos-go/api/v1/lib/scheduler" 9 | "github.com/mesos/mesos-go/api/v1/lib/scheduler/calls" 10 | ) 11 | 12 | func TestRole(t *testing.T) { 13 | var ( 14 | rolesNone []string 15 | roleX = []string{"x"} 16 | ) 17 | for ti, tc := range []struct { 18 | call *scheduler.Call 19 | roles []string 20 | }{ 21 | {calls.Revive(), rolesNone}, 22 | {calls.Suppress(), rolesNone}, 23 | 24 | {calls.ReviveWith(nil), rolesNone}, 25 | {calls.SuppressWith(nil), rolesNone}, 26 | 27 | {calls.ReviveWith(roleX), roleX}, 28 | {calls.SuppressWith(roleX), roleX}, 29 | } { 30 | roles, hasRole := func() ([]string, bool) { 31 | switch tc.call.Type { 32 | case scheduler.Call_SUPPRESS: 33 | return tc.call.GetSuppress().GetRoles(), len(tc.call.GetSuppress().GetRoles()) > 0 34 | case scheduler.Call_REVIVE: 35 | return tc.call.GetRevive().GetRoles(), len(tc.call.GetRevive().GetRoles()) > 0 36 | default: 37 | panic(fmt.Sprintf("test case %d failed: unsupported call type: %v", ti, tc.call.Type)) 38 | } 39 | }() 40 | if hasRole != (len(tc.roles) > 0) { 41 | if hasRole { 42 | t.Errorf("test case %d failed: expected no role instead of %q", ti, roles) 43 | } else { 44 | t.Errorf("test case %d failed: expected role %q instead of no role", ti, tc.roles) 45 | } 46 | } 47 | if hasRole && !reflect.DeepEqual(tc.roles, roles) { 48 | t.Errorf("test case %d failed: expected role %q instead of %q", ti, tc.roles, roles) 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /api/v1/lib/time/time_test.go: -------------------------------------------------------------------------------- 1 | package time_test 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | 7 | . "github.com/mesos/mesos-go/api/v1/lib/time" 8 | ) 9 | 10 | func TestParseDuration(t *testing.T) { 11 | for i, tc := range []struct { 12 | input string 13 | output time.Duration 14 | wantsError bool 15 | }{ 16 | {wantsError: true}, 17 | {input: "1ns", output: time.Duration(1)}, 18 | {input: "1.5ns", output: time.Duration(1)}, 19 | {input: "1.9ns", output: time.Duration(1)}, 20 | {input: "1us", output: 1 * time.Microsecond}, 21 | {input: "1.5us", output: 1*time.Microsecond + 500}, 22 | {input: "1ms", output: 1 * time.Millisecond}, 23 | {input: "1secs", output: 1 * time.Second}, 24 | {input: "1mins", output: 1 * time.Minute}, 25 | {input: "1hrs", output: 1 * time.Hour}, 26 | {input: "1days", output: 1 * time.Hour * 24}, 27 | {input: "1weeks", output: 1 * time.Hour * 24 * 7}, 28 | {input: "1", wantsError: true}, 29 | {input: "1.0", wantsError: true}, 30 | {input: "1.0.0ns", wantsError: true}, 31 | {input: "a1ns", wantsError: true}, 32 | {input: "ns", wantsError: true}, 33 | {input: "1ms1ns", wantsError: true}, 34 | } { 35 | d, err := ParseDuration(tc.input) 36 | if err != nil && tc.wantsError { 37 | continue 38 | } 39 | if err != nil { 40 | t.Errorf("test case %d failed: unexpected error %+v", i, err) 41 | } else if tc.wantsError { 42 | t.Errorf("test case %d failed: expected error for input %q", i, tc.input) 43 | } else if tc.output != d { 44 | t.Errorf("test case %d failed: expected output %v instead of %v", i, tc.output, d) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/pborman/uuid/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009,2014 Google Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /api/v0/healthchecker/health_checker.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package healthchecker 20 | 21 | import ( 22 | "time" 23 | 24 | "github.com/mesos/mesos-go/api/v0/upid" 25 | ) 26 | 27 | // HealthChecker defines the interface of a health checker. 28 | type HealthChecker interface { 29 | // Start will start the health checker, and returns a notification channel. 30 | // if the checker thinks the slave is unhealthy, it will send the timestamp 31 | // via the channel. 32 | Start() <-chan time.Time 33 | // Pause will pause the slave health checker. 34 | Pause() 35 | // Continue will continue the slave health checker with a new slave upid. 36 | Continue(slaveUPID *upid.UPID) 37 | // Stop will stop the health checker. it should be called only once during 38 | // the life span of the checker. 39 | Stop() 40 | } 41 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/mesos/mesos-go", 3 | "GoVersion": "go1.4.2", 4 | "Packages": [ 5 | "./..." 6 | ], 7 | "Deps": [ 8 | { 9 | "ImportPath": "github.com/gogo/protobuf/proto", 10 | "Comment": "v0.1-55-g2093b57", 11 | "Rev": "2093b57e5ca2ccbee4626814100bc1aada691b18" 12 | }, 13 | { 14 | "ImportPath": "github.com/golang/glog", 15 | "Rev": "d1c4472bf2efd3826f2b5bdcc02d8416798d678c" 16 | }, 17 | { 18 | "ImportPath": "github.com/pborman/uuid", 19 | "Rev": "ca53cad383cad2479bbba7f7a1a05797ec1386e4" 20 | }, 21 | { 22 | "ImportPath": "github.com/samuel/go-zookeeper/zk", 23 | "Rev": "177002e16a0061912f02377e2dd8951a8b3551bc" 24 | }, 25 | { 26 | "ImportPath": "github.com/stretchr/objx", 27 | "Rev": "cbeaeb16a013161a98496fad62933b1d21786672" 28 | }, 29 | { 30 | "ImportPath": "github.com/stretchr/testify/assert", 31 | "Comment": "v1.0-21-gf552045", 32 | "Rev": "f5520455607c0233cb6d7b056f71b22c1d265ef1" 33 | }, 34 | { 35 | "ImportPath": "github.com/stretchr/testify/mock", 36 | "Comment": "v1.0-21-gf552045", 37 | "Rev": "f5520455607c0233cb6d7b056f71b22c1d265ef1" 38 | }, 39 | { 40 | "ImportPath": "github.com/stretchr/testify/require", 41 | "Comment": "v1.0-21-gf552045", 42 | "Rev": "f5520455607c0233cb6d7b056f71b22c1d265ef1" 43 | }, 44 | { 45 | "ImportPath": "github.com/stretchr/testify/suite", 46 | "Comment": "v1.0-21-gf552045", 47 | "Rev": "f5520455607c0233cb6d7b056f71b22c1d265ef1" 48 | }, 49 | { 50 | "ImportPath": "golang.org/x/net/context", 51 | "Rev": "cbcac7bb8415db9b6cb4d1ebab1dc9afbd688b97" 52 | } 53 | ] 54 | } 55 | -------------------------------------------------------------------------------- /api/v0/detector/factory_test.go: -------------------------------------------------------------------------------- 1 | package detector 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | type testDetector string 10 | 11 | func (d testDetector) Start() error { return nil } 12 | func (d testDetector) Detect(f MasterChanged) error { return nil } 13 | 14 | func (d testDetector) Done() <-chan struct{} { return make(<-chan struct{}) } 15 | func (d testDetector) Cancel() {} 16 | 17 | // unregister a factory plugin according to its prefix. 18 | // this is part of the testing module on purpose: during normal execution there 19 | // should be no need to dynamically unregister plugins. 20 | func Unregister(prefix string) { 21 | pluginLock.Lock() 22 | defer pluginLock.Unlock() 23 | delete(plugins, prefix) 24 | } 25 | 26 | func TestDetectorFactoryRegister(t *testing.T) { 27 | prefix := "bbm:" 28 | Register(prefix, func(spec string, _ ...Option) (Master, error) { 29 | return testDetector("Hello!"), nil 30 | }) 31 | defer Unregister(prefix) 32 | 33 | f, ok := MatchingPlugin(prefix) 34 | 35 | assert.True(t, ok) 36 | assert.NotNil(t, f) 37 | } 38 | 39 | func TestDectorFactoryNew_EmptySpec(t *testing.T) { 40 | assert := assert.New(t) 41 | m, err := New("") 42 | assert.NotNil(err) 43 | assert.Nil(m) 44 | } 45 | 46 | func TestDectorFactoryNew_InvalidSpec(t *testing.T) { 47 | assert := assert.New(t) 48 | m, err := New("localhost") 49 | assert.NotNil(err) 50 | assert.Nil(m) 51 | } 52 | 53 | func TestDectorFactoryNew_TrivialSpec(t *testing.T) { 54 | assert := assert.New(t) 55 | m, err := New("localhost:1") 56 | assert.NoError(err) 57 | assert.NotNil(m) 58 | assert.IsType(&Standalone{}, m) 59 | } 60 | -------------------------------------------------------------------------------- /api/v1/lib/executor/calls/calls.go: -------------------------------------------------------------------------------- 1 | package calls 2 | 3 | import ( 4 | "github.com/mesos/mesos-go/api/v1/lib" 5 | "github.com/mesos/mesos-go/api/v1/lib/executor" 6 | ) 7 | 8 | // Framework sets a executor.Call's FrameworkID 9 | func Framework(id string) executor.CallOpt { 10 | return func(c *executor.Call) { 11 | c.FrameworkID = mesos.FrameworkID{Value: id} 12 | } 13 | } 14 | 15 | // Executor sets a executor.Call's ExecutorID 16 | func Executor(id string) executor.CallOpt { 17 | return func(c *executor.Call) { 18 | c.ExecutorID = mesos.ExecutorID{Value: id} 19 | } 20 | } 21 | 22 | // Subscribe returns an executor call with the given parameters. 23 | func Subscribe(unackdTasks []mesos.TaskInfo, unackdUpdates []executor.Call_Update) *executor.Call { 24 | return &executor.Call{ 25 | Type: executor.Call_SUBSCRIBE, 26 | Subscribe: &executor.Call_Subscribe{ 27 | UnacknowledgedTasks: unackdTasks, 28 | UnacknowledgedUpdates: unackdUpdates, 29 | }, 30 | } 31 | } 32 | 33 | // Update returns an executor call with the given parameters. 34 | func Update(status mesos.TaskStatus) *executor.Call { 35 | return &executor.Call{ 36 | Type: executor.Call_UPDATE, 37 | Update: &executor.Call_Update{ 38 | Status: status, 39 | }, 40 | } 41 | } 42 | 43 | // Message returns an executor call with the given parameters. 44 | func Message(data []byte) *executor.Call { 45 | return &executor.Call{ 46 | Type: executor.Call_MESSAGE, 47 | Message: &executor.Call_Message{ 48 | Data: data, 49 | }, 50 | } 51 | } 52 | 53 | // Heartbeat returns an executor heartbeat call, useful to detect disconnections. 54 | func Heartbeat() *executor.Call { 55 | return &executor.Call{ 56 | Type: executor.Call_HEARTBEAT, 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /api/v1/lib/extras/executor/eventrules/metrics_generated.go: -------------------------------------------------------------------------------- 1 | package eventrules 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/executor -type E:*executor.Event:&executor.Event{} -type ET:executor.Event_Type -output metrics_generated.go 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | 9 | "strings" 10 | 11 | "github.com/mesos/mesos-go/api/v1/lib/extras/metrics" 12 | 13 | "github.com/mesos/mesos-go/api/v1/lib/executor" 14 | ) 15 | 16 | // Labeler generates a set of strings that should be associated with metrics that are generated for the given event. 17 | type Labeler func(ctx context.Context, e *executor.Event) []string 18 | 19 | var defaultLabels = func() map[executor.Event_Type][]string { 20 | m := make(map[executor.Event_Type][]string) 21 | for k, v := range executor.Event_Type_name { 22 | m[executor.Event_Type(k)] = []string{strings.ToLower(v)} 23 | } 24 | return m 25 | }() 26 | 27 | func defaultLabeler(ctx context.Context, e *executor.Event) []string { 28 | return defaultLabels[e.GetType()] 29 | } 30 | 31 | // Metrics generates a Rule that invokes the given harness for each event, using the labels generated by the Labeler. 32 | // Panics if harness or labeler is nil. 33 | func Metrics(harness metrics.Harness, labeler Labeler) Rule { 34 | if harness == nil { 35 | panic("harness is a required parameter") 36 | } 37 | if labeler == nil { 38 | labeler = defaultLabeler 39 | } 40 | return func(ctx context.Context, e *executor.Event, err error, ch Chain) (context.Context, *executor.Event, error) { 41 | labels := labeler(ctx, e) 42 | harness(func() error { 43 | ctx, e, err = ch(ctx, e, err) 44 | return err 45 | }, labels...) 46 | return ctx, e, err 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /api/v0/examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | ## Building 4 | ``` 5 | $ go get github.com/tools/godep 6 | $ make 7 | ``` 8 | 9 | ## Running 10 | ### Start Mesos 11 | You will need a running Mesos master and slaves to run the examples. For instance, start a local Mesos: 12 | ``` 13 | $ /bin/mesos-local --ip=127.0.0.1 --port=5050 --roles=golang 14 | ``` 15 | See http://mesos.apache.org/gettingstarted/ for getting started with Apache Mesos. 16 | 17 | ### Start the Go scheduler/executor examples 18 | ``` 19 | $ export EXECUTOR_BIN=$(pwd)/_output/executor 20 | $ ./_output/scheduler -master=127.0.0.1:5050 -executor="$EXECUTOR_BIN" -logtostderr=true 21 | ``` 22 | If all goes well, you should see output about task completion. 23 | You can also point your browser to the Mesos GUI http://127.0.0.1:5050/ to validate the framework activities. 24 | 25 | ### Start the Go scheduler with other executors 26 | You can also use the Go `example-scheduler` with executors written in other languages such as `Python` or `Java` for further validation (note: to use these executors requires a build of the mesos source code with `make check`): 27 | ``` 28 | $ ./_output/scheduler -master=127.0.0.1:5050 -executor="/src/examples/python/test-executor" -logtostderr=true 29 | ``` 30 | Similarly for the Java version: 31 | ``` 32 | $ ./_output/scheduler -master=127.0.0.1:5050 -executor="/src/examples/java/test-executor" -logtostderr=true 33 | ``` 34 | 35 | ### Start the Go persistent scheduler/executor examples 36 | ``` 37 | $ export EXECUTOR_BIN=$(pwd)/_output/executor 38 | $ ./_output/persistent_scheduler -master=127.0.0.1:5050 -executor="$EXECUTOR_BIN" -logtostderr=true -role=golang -mesos_authentication_principal=golang 39 | ``` 40 | -------------------------------------------------------------------------------- /api/v1/lib/extras/scheduler/eventrules/metrics_generated.go: -------------------------------------------------------------------------------- 1 | package eventrules 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/scheduler -type E:*scheduler.Event:&scheduler.Event{} -type ET:scheduler.Event_Type -output metrics_generated.go 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | 9 | "strings" 10 | 11 | "github.com/mesos/mesos-go/api/v1/lib/extras/metrics" 12 | 13 | "github.com/mesos/mesos-go/api/v1/lib/scheduler" 14 | ) 15 | 16 | // Labeler generates a set of strings that should be associated with metrics that are generated for the given event. 17 | type Labeler func(ctx context.Context, e *scheduler.Event) []string 18 | 19 | var defaultLabels = func() map[scheduler.Event_Type][]string { 20 | m := make(map[scheduler.Event_Type][]string) 21 | for k, v := range scheduler.Event_Type_name { 22 | m[scheduler.Event_Type(k)] = []string{strings.ToLower(v)} 23 | } 24 | return m 25 | }() 26 | 27 | func defaultLabeler(ctx context.Context, e *scheduler.Event) []string { 28 | return defaultLabels[e.GetType()] 29 | } 30 | 31 | // Metrics generates a Rule that invokes the given harness for each event, using the labels generated by the Labeler. 32 | // Panics if harness or labeler is nil. 33 | func Metrics(harness metrics.Harness, labeler Labeler) Rule { 34 | if harness == nil { 35 | panic("harness is a required parameter") 36 | } 37 | if labeler == nil { 38 | labeler = defaultLabeler 39 | } 40 | return func(ctx context.Context, e *scheduler.Event, err error, ch Chain) (context.Context, *scheduler.Event, error) { 41 | labels := labeler(ctx, e) 42 | harness(func() error { 43 | ctx, e, err = ch(ctx, e, err) 44 | return err 45 | }, labels...) 46 | return ctx, e, err 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/pborman/uuid/seq_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "flag" 9 | "runtime" 10 | "testing" 11 | "time" 12 | ) 13 | 14 | // This test is only run when --regressions is passed on the go test line. 15 | var regressions = flag.Bool("regressions", false, "run uuid regression tests") 16 | 17 | // TestClockSeqRace tests for a particular race condition of returning two 18 | // identical Version1 UUIDs. The duration of 1 minute was chosen as the race 19 | // condition, before being fixed, nearly always occured in under 30 seconds. 20 | func TestClockSeqRace(t *testing.T) { 21 | if !*regressions { 22 | t.Skip("skipping regression tests") 23 | } 24 | duration := time.Minute 25 | 26 | done := make(chan struct{}) 27 | defer close(done) 28 | 29 | ch := make(chan UUID, 10000) 30 | ncpu := runtime.NumCPU() 31 | switch ncpu { 32 | case 0, 1: 33 | // We can't run the test effectively. 34 | t.Skip("skipping race test, only one CPU detected") 35 | return 36 | default: 37 | runtime.GOMAXPROCS(ncpu) 38 | } 39 | for i := 0; i < ncpu; i++ { 40 | go func() { 41 | for { 42 | select { 43 | case <-done: 44 | return 45 | case ch <- NewUUID(): 46 | } 47 | } 48 | }() 49 | } 50 | 51 | uuids := make(map[string]bool) 52 | cnt := 0 53 | start := time.Now() 54 | for u := range ch { 55 | s := u.String() 56 | if uuids[s] { 57 | t.Errorf("duplicate uuid after %d in %v: %s", cnt, time.Since(start), s) 58 | return 59 | } 60 | uuids[s] = true 61 | if time.Since(start) > duration { 62 | return 63 | } 64 | cnt++ 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /api/v0/messenger/message.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package messenger 20 | 21 | import ( 22 | "fmt" 23 | "strings" 24 | 25 | "github.com/gogo/protobuf/proto" 26 | "github.com/mesos/mesos-go/api/v0/upid" 27 | ) 28 | 29 | // Message defines the type that passes in the Messenger. 30 | type Message struct { 31 | UPID *upid.UPID 32 | Name string 33 | ProtoMessage proto.Message 34 | Bytes []byte 35 | } 36 | 37 | // RequestURI returns the request URI of the message. 38 | func (m *Message) RequestURI() string { 39 | if m.isV1API() { 40 | return fmt.Sprintf("/api/v1/%s", m.Name) 41 | } 42 | 43 | return fmt.Sprintf("/%s/%s", m.UPID.ID, m.Name) 44 | } 45 | 46 | func (m *Message) isV1API() bool { 47 | return !strings.HasPrefix(m.Name, "mesos.internal") 48 | } 49 | 50 | // NOTE: This should not fail or panic. 51 | func extractNameFromRequestURI(requestURI string) string { 52 | return strings.Split(requestURI, "/")[2] 53 | } 54 | -------------------------------------------------------------------------------- /api/v1/lib/extras/metrics/metrics.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | func InMicroseconds(d time.Duration) float64 { 8 | return float64(d.Nanoseconds() / time.Microsecond.Nanoseconds()) 9 | } 10 | 11 | type ( 12 | Counter func(...string) 13 | Adder func(float64, ...string) 14 | Watcher func(float64, ...string) 15 | ) 16 | 17 | // Int adds the value of `x`; convenience func for adding integers. 18 | func (a Adder) Int(x int, s ...string) { 19 | a(float64(x), s...) 20 | } 21 | 22 | // Since records an observation of time.Now().Sub(t) in microseconds 23 | func (w Watcher) Since(t time.Time, s ...string) { 24 | w(InMicroseconds(time.Now().Sub(t)), s...) 25 | } 26 | 27 | // Harness funcs execute the given func and record metrics concerning the execution. The error 28 | // returned from the harness is the same error returned from the execution of the func param. 29 | type Harness func(func() error, ...string) error 30 | 31 | // NewHarness generates and returns an execution harness that records metrics. `counts` and `errors` 32 | // are required; `timed` and `clock` must either both be nil, or both be non-nil. 33 | func NewHarness(counts, errors Counter, timed Watcher, clock func() time.Time) Harness { 34 | var harness Harness 35 | if timed != nil && clock != nil { 36 | harness = func(f func() error, labels ...string) error { 37 | counts(labels...) 38 | var ( 39 | t = clock() 40 | err = f() 41 | ) 42 | timed.Since(t, labels...) 43 | if err != nil { 44 | errors(labels...) 45 | } 46 | return err 47 | } 48 | } else { 49 | harness = func(f func() error, labels ...string) error { 50 | counts(labels...) 51 | err := f() 52 | if err != nil { 53 | errors(labels...) 54 | } 55 | return err 56 | } 57 | } 58 | return harness 59 | } 60 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/testify/mock/doc.go: -------------------------------------------------------------------------------- 1 | // Provides a system by which it is possible to mock your objects and verify calls are happening as expected. 2 | // 3 | // Example Usage 4 | // 5 | // The mock package provides an object, Mock, that tracks activity on another object. It is usually 6 | // embedded into a test object as shown below: 7 | // 8 | // type MyTestObject struct { 9 | // // add a Mock object instance 10 | // mock.Mock 11 | // 12 | // // other fields go here as normal 13 | // } 14 | // 15 | // When implementing the methods of an interface, you wire your functions up 16 | // to call the Mock.Called(args...) method, and return the appropriate values. 17 | // 18 | // For example, to mock a method that saves the name and age of a person and returns 19 | // the year of their birth or an error, you might write this: 20 | // 21 | // func (o *MyTestObject) SavePersonDetails(firstname, lastname string, age int) (int, error) { 22 | // args := o.Called(firstname, lastname, age) 23 | // return args.Int(0), args.Error(1) 24 | // } 25 | // 26 | // The Int, Error and Bool methods are examples of strongly typed getters that take the argument 27 | // index position. Given this argument list: 28 | // 29 | // (12, true, "Something") 30 | // 31 | // You could read them out strongly typed like this: 32 | // 33 | // args.Int(0) 34 | // args.Bool(1) 35 | // args.String(2) 36 | // 37 | // For objects of your own type, use the generic Arguments.Get(index) method and make a type assertion: 38 | // 39 | // return args.Get(0).(*MyObject), args.Get(1).(*AnotherObjectOfMine) 40 | // 41 | // This may cause a panic if the object you are getting is nil (the type assertion will fail), in those 42 | // cases you should check for nil first. 43 | package mock 44 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | ## Issues 3 | When filing an issue, make sure to answer these five questions: 4 | 5 | 1. What version of the project are you using? 6 | 2. What operating system and processor architecture are you using? 7 | 3. What did you do? 8 | 4. What did you expect to see? 9 | 5. What did you see instead? 10 | 11 | ## Code 12 | ### Proposals 13 | Non trivial changes should be first discussed with the project maintainers by 14 | opening a Github issue with the "Proposal: " title prefix, clearly explaining 15 | rationale, context and implementation ideas. 16 | 17 | This separate step is encouraged but not required. 18 | 19 | ### Implementation 20 | Work should happen in an open pull request having a WIP prefix in its 21 | title which gives visibility to the development process and provides 22 | continuous integration feedback. 23 | 24 | The pull request description must be well written and provide the necessary 25 | context and background for review. If there's a proposal issue, it must be 26 | referenced. When ready, replace the WIP prefix with PTAL which will 27 | bring your contribution to the attention of project maintainers who will review 28 | your PR in a timely manner. 29 | 30 | Before review, keep in mind that: 31 | - Git commit messages should conform to [community standards](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). 32 | - Git commits should represent meaningful milestones or units of work. 33 | - Changed or added code must be well tested. Different kinds of code 34 | require different testing strategies. 35 | - Changed or added code must pass the project's CI. 36 | - Changes to vendored files must be grouped into a single commit. 37 | 38 | Once comments and revisions on the implementation wind down, the reviewers will 39 | add the LGTM label which marks the PR as merge-able. 40 | -------------------------------------------------------------------------------- /api/v1/lib/extras/executor/eventrules/handlers_generated.go: -------------------------------------------------------------------------------- 1 | package eventrules 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/executor -import github.com/mesos/mesos-go/api/v1/lib/executor/events -type E:*executor.Event -type H:events.Handler -type HF:events.HandlerFunc -output handlers_generated.go 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | 9 | "github.com/mesos/mesos-go/api/v1/lib/executor" 10 | "github.com/mesos/mesos-go/api/v1/lib/executor/events" 11 | ) 12 | 13 | // Handle generates a rule that executes the given events.Handler. 14 | func Handle(h events.Handler) Rule { 15 | if h == nil { 16 | return nil 17 | } 18 | return func(ctx context.Context, e *executor.Event, err error, chain Chain) (context.Context, *executor.Event, error) { 19 | newErr := h.HandleEvent(ctx, e) 20 | return chain(ctx, e, Error2(err, newErr)) 21 | } 22 | } 23 | 24 | // HandleF is the functional equivalent of Handle 25 | func HandleF(h events.HandlerFunc) Rule { 26 | return Handle(events.Handler(h)) 27 | } 28 | 29 | // Handle returns a Rule that invokes the receiver, then the given events.Handler 30 | func (r Rule) Handle(h events.Handler) Rule { 31 | return Rules{r, Handle(h)}.Eval 32 | } 33 | 34 | // HandleF is the functional equivalent of Handle 35 | func (r Rule) HandleF(h events.HandlerFunc) Rule { 36 | return r.Handle(events.Handler(h)) 37 | } 38 | 39 | // HandleEvent implements events.Handler for Rule 40 | func (r Rule) HandleEvent(ctx context.Context, e *executor.Event) (err error) { 41 | if r == nil { 42 | return nil 43 | } 44 | _, _, err = r(ctx, e, nil, ChainIdentity) 45 | return 46 | } 47 | 48 | // HandleEvent implements events.Handler for Rules 49 | func (rs Rules) HandleEvent(ctx context.Context, e *executor.Event) error { 50 | return Rule(rs.Eval).HandleEvent(ctx, e) 51 | } 52 | -------------------------------------------------------------------------------- /api/v0/examples/flagcheck/flagcheck.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | 8 | // Import all non-testing packages to verify that flags are not added 9 | // to the command line. 10 | 11 | _ "github.com/mesos/mesos-go/api/v0/auth" 12 | _ "github.com/mesos/mesos-go/api/v0/auth/callback" 13 | _ "github.com/mesos/mesos-go/api/v0/auth/sasl" 14 | _ "github.com/mesos/mesos-go/api/v0/auth/sasl/mech" 15 | _ "github.com/mesos/mesos-go/api/v0/auth/sasl/mech/crammd5" 16 | _ "github.com/mesos/mesos-go/api/v0/detector" 17 | _ "github.com/mesos/mesos-go/api/v0/detector/zoo" 18 | _ "github.com/mesos/mesos-go/api/v0/executor" 19 | _ "github.com/mesos/mesos-go/api/v0/healthchecker" 20 | _ "github.com/mesos/mesos-go/api/v0/mesosproto" 21 | _ "github.com/mesos/mesos-go/api/v0/mesosproto/scheduler" 22 | _ "github.com/mesos/mesos-go/api/v0/mesosutil" 23 | _ "github.com/mesos/mesos-go/api/v0/mesosutil/process" 24 | _ "github.com/mesos/mesos-go/api/v0/messenger" 25 | _ "github.com/mesos/mesos-go/api/v0/messenger/sessionid" 26 | _ "github.com/mesos/mesos-go/api/v0/scheduler" 27 | _ "github.com/mesos/mesos-go/api/v0/upid" 28 | ) 29 | 30 | // Flags which are accepted from other packages. 31 | var allowedFlags = []string{ 32 | // Flags added from the glog package 33 | "logtostderr", 34 | "alsologtostderr", 35 | "v", 36 | "stderrthreshold", 37 | "vmodule", 38 | "log_backtrace_at", 39 | "log_dir", 40 | } 41 | 42 | func main() { 43 | expected := map[string]struct{}{} 44 | for _, f := range allowedFlags { 45 | expected[f] = struct{}{} 46 | } 47 | 48 | hasLeak := false 49 | flag.CommandLine.VisitAll(func(f *flag.Flag) { 50 | if _, ok := expected[f.Name]; !ok { 51 | fmt.Fprintf(os.Stderr, "Leaking flag %q: %q\n", f.Name, f.Usage) 52 | hasLeak = true 53 | } 54 | }) 55 | 56 | if hasLeak { 57 | os.Exit(1) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /api/v1/lib/extras/scheduler/eventrules/handlers_generated.go: -------------------------------------------------------------------------------- 1 | package eventrules 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/scheduler -import github.com/mesos/mesos-go/api/v1/lib/scheduler/events -type E:*scheduler.Event -type H:events.Handler -type HF:events.HandlerFunc -output handlers_generated.go 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | 9 | "github.com/mesos/mesos-go/api/v1/lib/scheduler" 10 | "github.com/mesos/mesos-go/api/v1/lib/scheduler/events" 11 | ) 12 | 13 | // Handle generates a rule that executes the given events.Handler. 14 | func Handle(h events.Handler) Rule { 15 | if h == nil { 16 | return nil 17 | } 18 | return func(ctx context.Context, e *scheduler.Event, err error, chain Chain) (context.Context, *scheduler.Event, error) { 19 | newErr := h.HandleEvent(ctx, e) 20 | return chain(ctx, e, Error2(err, newErr)) 21 | } 22 | } 23 | 24 | // HandleF is the functional equivalent of Handle 25 | func HandleF(h events.HandlerFunc) Rule { 26 | return Handle(events.Handler(h)) 27 | } 28 | 29 | // Handle returns a Rule that invokes the receiver, then the given events.Handler 30 | func (r Rule) Handle(h events.Handler) Rule { 31 | return Rules{r, Handle(h)}.Eval 32 | } 33 | 34 | // HandleF is the functional equivalent of Handle 35 | func (r Rule) HandleF(h events.HandlerFunc) Rule { 36 | return r.Handle(events.Handler(h)) 37 | } 38 | 39 | // HandleEvent implements events.Handler for Rule 40 | func (r Rule) HandleEvent(ctx context.Context, e *scheduler.Event) (err error) { 41 | if r == nil { 42 | return nil 43 | } 44 | _, _, err = r(ctx, e, nil, ChainIdentity) 45 | return 46 | } 47 | 48 | // HandleEvent implements events.Handler for Rules 49 | func (rs Rules) HandleEvent(ctx context.Context, e *scheduler.Event) error { 50 | return Rule(rs.Eval).HandleEvent(ctx, e) 51 | } 52 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/gogo/protobuf/proto/lib_gogo.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. 2 | // http://github.com/gogo/protobuf/gogoproto 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package proto 28 | 29 | import ( 30 | "encoding/json" 31 | "strconv" 32 | ) 33 | 34 | func MarshalJSONEnum(m map[int32]string, value int32) ([]byte, error) { 35 | s, ok := m[value] 36 | if !ok { 37 | s = strconv.Itoa(int(value)) 38 | } 39 | return json.Marshal(s) 40 | } 41 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/codegen/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Codegen 5 | 6 | 17 | 18 | 19 | 20 |

21 | Template 22 |

23 |

24 | Use {x} as a placeholder for each argument. 25 |

26 | 27 | 28 |

29 | Arguments (comma separated) 30 |

31 |

32 | One block per line 33 |

34 | 35 | 36 |

37 | Output 38 |

39 | 40 | 41 | 42 | 43 | 44 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /api/v1/lib/extras/gen/rule_handlers.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import ( 6 | "os" 7 | "text/template" 8 | ) 9 | 10 | func main() { 11 | Run(handlersTemplate, nil, os.Args...) 12 | } 13 | 14 | var handlersTemplate = template.Must(template.New("").Parse(`package {{.Package}} 15 | 16 | // go generate {{.Args}} 17 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 18 | 19 | import ( 20 | "context" 21 | {{range .Imports}} 22 | {{ printf "%q" . -}} 23 | {{end}} 24 | ) 25 | 26 | {{.RequireType "E" -}} 27 | {{.RequireType "H" -}} 28 | {{.RequireType "HF" -}} 29 | // Handle generates a rule that executes the given {{.Type "H"}}. 30 | func Handle(h {{.Type "H"}}) Rule { 31 | if h == nil { 32 | return nil 33 | } 34 | return func(ctx context.Context, e {{.Type "E"}}, err error, chain Chain) (context.Context, {{.Type "E"}}, error) { 35 | newErr := h.HandleEvent(ctx, e) 36 | return chain(ctx, e, Error2(err, newErr)) 37 | } 38 | } 39 | 40 | // HandleF is the functional equivalent of Handle 41 | func HandleF(h {{.Type "HF"}}) Rule { 42 | return Handle({{.Type "H"}}(h)) 43 | } 44 | 45 | // Handle returns a Rule that invokes the receiver, then the given {{.Type "H"}} 46 | func (r Rule) Handle(h {{.Type "H"}}) Rule { 47 | return Rules{r, Handle(h)}.Eval 48 | } 49 | 50 | // HandleF is the functional equivalent of Handle 51 | func (r Rule) HandleF(h {{.Type "HF"}}) Rule { 52 | return r.Handle({{.Type "H"}}(h)) 53 | } 54 | 55 | // HandleEvent implements {{.Type "H"}} for Rule 56 | func (r Rule) HandleEvent(ctx context.Context, e {{.Type "E"}}) (err error) { 57 | if r == nil { 58 | return nil 59 | } 60 | _, _, err = r(ctx, e, nil, ChainIdentity) 61 | return 62 | } 63 | 64 | // HandleEvent implements {{.Type "H"}} for Rules 65 | func (rs Rules) HandleEvent(ctx context.Context, e {{.Type "E"}}) error { 66 | return Rule(rs.Eval).HandleEvent(ctx, e) 67 | } 68 | `)) 69 | -------------------------------------------------------------------------------- /api/v1/cmd/example-scheduler/app/server.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net" 7 | "net/http" 8 | "os" 9 | "strconv" 10 | "strings" 11 | ) 12 | 13 | func serveFile(filename string) (handler http.Handler, err error) { 14 | _, err = os.Stat(filename) 15 | if err != nil { 16 | err = fmt.Errorf("failed to locate artifact: %+v", err) 17 | } else { 18 | handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 19 | http.ServeFile(w, r, filename) 20 | }) 21 | } 22 | return 23 | } 24 | 25 | // returns (downloadURI, basename(path)) 26 | func serveExecutorArtifact(server server, path string, mux *http.ServeMux) (string, string, error) { 27 | // Create base path (http://foobar:5000/) 28 | pathSplit := strings.Split(path, "/") 29 | var base string 30 | if len(pathSplit) > 0 { 31 | base = pathSplit[len(pathSplit)-1] 32 | } else { 33 | base = path 34 | } 35 | pattern := "/" + base 36 | h, err := serveFile(path) 37 | if err != nil { 38 | return "", "", err 39 | } 40 | 41 | mux.Handle(pattern, h) 42 | 43 | hostURI := fmt.Sprintf("http://%s:%d/%s", server.address, server.port, base) 44 | log.Println("Hosting artifact '" + path + "' at '" + hostURI + "'") 45 | 46 | return hostURI, base, nil 47 | } 48 | 49 | func newListener(server server) (*net.TCPListener, int, error) { 50 | addr, err := net.ResolveTCPAddr("tcp", net.JoinHostPort(server.address, strconv.Itoa(server.port))) 51 | if err != nil { 52 | return nil, 0, err 53 | } 54 | listener, err := net.ListenTCP("tcp", addr) 55 | if err != nil { 56 | return nil, 0, err 57 | } 58 | bindAddress := listener.Addr().String() 59 | _, port, err := net.SplitHostPort(bindAddress) 60 | if err != nil { 61 | return nil, 0, err 62 | } 63 | iport, err := strconv.Atoi(port) 64 | if err != nil { 65 | return nil, 0, err 66 | } 67 | return listener, iport, nil 68 | } 69 | -------------------------------------------------------------------------------- /api/v0/messenger/transporter.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package messenger 20 | 21 | import ( 22 | "github.com/mesos/mesos-go/api/v0/upid" 23 | "golang.org/x/net/context" 24 | ) 25 | 26 | // Transporter defines methods for communicating with remote processes. 27 | type Transporter interface { 28 | //Send sends message to remote process. Must use context to determine 29 | //cancelled requests. Will stop sending when transport is stopped. 30 | Send(ctx context.Context, msg *Message) error 31 | 32 | //Rcvd receives and delegate message handling to installed handlers. 33 | //Will stop receiving when transport is stopped. 34 | Recv() (*Message, error) 35 | 36 | //Install mount an handler based on incoming message name. 37 | Install(messageName string) 38 | 39 | //Start starts the transporter and returns immediately. The error chan 40 | //is never nil. 41 | Start() (upid.UPID, <-chan error) 42 | 43 | //Stop kills the transporter. 44 | Stop(graceful bool) error 45 | 46 | //UPID returns the PID for transporter. 47 | UPID() upid.UPID 48 | } 49 | -------------------------------------------------------------------------------- /api/v1/lib/extras/executor/callrules/metrics_generated.go: -------------------------------------------------------------------------------- 1 | package callrules 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib -import github.com/mesos/mesos-go/api/v1/lib/executor -type E:*executor.Call:&executor.Call{} -type ET:executor.Call_Type -type Z:mesos.Response:&mesos.ResponseWrapper{} -output metrics_generated.go 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | 9 | "strings" 10 | 11 | "github.com/mesos/mesos-go/api/v1/lib/extras/metrics" 12 | 13 | "github.com/mesos/mesos-go/api/v1/lib" 14 | "github.com/mesos/mesos-go/api/v1/lib/executor" 15 | ) 16 | 17 | // Labeler generates a set of strings that should be associated with metrics that are generated for the given event. 18 | type Labeler func(ctx context.Context, e *executor.Call) []string 19 | 20 | var defaultLabels = func() map[executor.Call_Type][]string { 21 | m := make(map[executor.Call_Type][]string) 22 | for k, v := range executor.Call_Type_name { 23 | m[executor.Call_Type(k)] = []string{strings.ToLower(v)} 24 | } 25 | return m 26 | }() 27 | 28 | func defaultLabeler(ctx context.Context, e *executor.Call) []string { 29 | return defaultLabels[e.GetType()] 30 | } 31 | 32 | // Metrics generates a Rule that invokes the given harness for each event, using the labels generated by the Labeler. 33 | // Panics if harness or labeler is nil. 34 | func Metrics(harness metrics.Harness, labeler Labeler) Rule { 35 | if harness == nil { 36 | panic("harness is a required parameter") 37 | } 38 | if labeler == nil { 39 | labeler = defaultLabeler 40 | } 41 | return func(ctx context.Context, e *executor.Call, z mesos.Response, err error, ch Chain) (context.Context, *executor.Call, mesos.Response, error) { 42 | labels := labeler(ctx, e) 43 | harness(func() error { 44 | ctx, e, z, err = ch(ctx, e, z, err) 45 | return err 46 | }, labels...) 47 | return ctx, e, z, err 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/httpagent/httpagent_generated.go: -------------------------------------------------------------------------------- 1 | package httpagent 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/agent -import github.com/mesos/mesos-go/api/v1/lib/agent/calls -type C:agent.Call:agent.Call{Type:agent.Call_GET_METRICS} 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | 9 | "github.com/mesos/mesos-go/api/v1/lib" 10 | "github.com/mesos/mesos-go/api/v1/lib/client" 11 | "github.com/mesos/mesos-go/api/v1/lib/httpcli" 12 | 13 | "github.com/mesos/mesos-go/api/v1/lib/agent" 14 | "github.com/mesos/mesos-go/api/v1/lib/agent/calls" 15 | ) 16 | 17 | // ResponseClassifier determines the appropriate response class for the given call. 18 | type ResponseClassifier func(*agent.Call) (client.ResponseClass, error) 19 | 20 | // ClientFunc sends a Request to Mesos and returns the generated Response. 21 | type ClientFunc func(client.Request, client.ResponseClass, ...httpcli.RequestOpt) (mesos.Response, error) 22 | 23 | // DefaultResponseClassifier is a pluggable classifier. 24 | var DefaultResponseClassifier = ResponseClassifier(classifyResponse) 25 | 26 | // NewSender generates a sender that uses the Mesos v1 HTTP API for encoding/decoding requests/responses. 27 | // The ResponseClass is inferred from the first object generated by the given Request. 28 | func NewSender(cf ClientFunc, ro ...httpcli.RequestOpt) calls.Sender { 29 | return calls.SenderFunc(func(ctx context.Context, r calls.Request) (mesos.Response, error) { 30 | var ( 31 | obj = r.Call() 32 | rc, err = DefaultResponseClassifier(obj) 33 | ) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | var req client.Request 39 | 40 | switch r := r.(type) { 41 | case calls.RequestStreaming: 42 | req = calls.Push(r, obj) 43 | default: 44 | req = calls.NonStreaming(obj) 45 | } 46 | 47 | return cf(req, rc, append(ro, httpcli.Context(ctx))...) 48 | }) 49 | } 50 | -------------------------------------------------------------------------------- /api/v1/lib/extras/scheduler/callrules/metrics_generated.go: -------------------------------------------------------------------------------- 1 | package callrules 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib -import github.com/mesos/mesos-go/api/v1/lib/scheduler -type E:*scheduler.Call:&scheduler.Call{} -type ET:scheduler.Call_Type -type Z:mesos.Response:&mesos.ResponseWrapper{} -output metrics_generated.go 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | 9 | "strings" 10 | 11 | "github.com/mesos/mesos-go/api/v1/lib/extras/metrics" 12 | 13 | "github.com/mesos/mesos-go/api/v1/lib" 14 | "github.com/mesos/mesos-go/api/v1/lib/scheduler" 15 | ) 16 | 17 | // Labeler generates a set of strings that should be associated with metrics that are generated for the given event. 18 | type Labeler func(ctx context.Context, e *scheduler.Call) []string 19 | 20 | var defaultLabels = func() map[scheduler.Call_Type][]string { 21 | m := make(map[scheduler.Call_Type][]string) 22 | for k, v := range scheduler.Call_Type_name { 23 | m[scheduler.Call_Type(k)] = []string{strings.ToLower(v)} 24 | } 25 | return m 26 | }() 27 | 28 | func defaultLabeler(ctx context.Context, e *scheduler.Call) []string { 29 | return defaultLabels[e.GetType()] 30 | } 31 | 32 | // Metrics generates a Rule that invokes the given harness for each event, using the labels generated by the Labeler. 33 | // Panics if harness or labeler is nil. 34 | func Metrics(harness metrics.Harness, labeler Labeler) Rule { 35 | if harness == nil { 36 | panic("harness is a required parameter") 37 | } 38 | if labeler == nil { 39 | labeler = defaultLabeler 40 | } 41 | return func(ctx context.Context, e *scheduler.Call, z mesos.Response, err error, ch Chain) (context.Context, *scheduler.Call, mesos.Response, error) { 42 | labels := labeler(ctx, e) 43 | harness(func() error { 44 | ctx, e, z, err = ch(ctx, e, z, err) 45 | return err 46 | }, labels...) 47 | return ctx, e, z, err 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/httpmaster/httpmaster_generated.go: -------------------------------------------------------------------------------- 1 | package httpmaster 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/master -import github.com/mesos/mesos-go/api/v1/lib/master/calls -type C:master.Call:master.Call{Type:master.Call_GET_METRICS} 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | 9 | "github.com/mesos/mesos-go/api/v1/lib" 10 | "github.com/mesos/mesos-go/api/v1/lib/client" 11 | "github.com/mesos/mesos-go/api/v1/lib/httpcli" 12 | 13 | "github.com/mesos/mesos-go/api/v1/lib/master" 14 | "github.com/mesos/mesos-go/api/v1/lib/master/calls" 15 | ) 16 | 17 | // ResponseClassifier determines the appropriate response class for the given call. 18 | type ResponseClassifier func(*master.Call) (client.ResponseClass, error) 19 | 20 | // ClientFunc sends a Request to Mesos and returns the generated Response. 21 | type ClientFunc func(client.Request, client.ResponseClass, ...httpcli.RequestOpt) (mesos.Response, error) 22 | 23 | // DefaultResponseClassifier is a pluggable classifier. 24 | var DefaultResponseClassifier = ResponseClassifier(classifyResponse) 25 | 26 | // NewSender generates a sender that uses the Mesos v1 HTTP API for encoding/decoding requests/responses. 27 | // The ResponseClass is inferred from the first object generated by the given Request. 28 | func NewSender(cf ClientFunc, ro ...httpcli.RequestOpt) calls.Sender { 29 | return calls.SenderFunc(func(ctx context.Context, r calls.Request) (mesos.Response, error) { 30 | var ( 31 | obj = r.Call() 32 | rc, err = DefaultResponseClassifier(obj) 33 | ) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | var req client.Request 39 | 40 | switch r := r.(type) { 41 | case calls.RequestStreaming: 42 | req = calls.Push(r, obj) 43 | default: 44 | req = calls.NonStreaming(obj) 45 | } 46 | 47 | return cf(req, rc, append(ro, httpcli.Context(ctx))...) 48 | }) 49 | } 50 | -------------------------------------------------------------------------------- /api/v0/messenger/README.md: -------------------------------------------------------------------------------- 1 | ####Benchmark of the messenger. 2 | 3 | ```shell 4 | $ go test -v -run=Benckmark* -bench=. 5 | PASS 6 | BenchmarkMessengerSendSmallMessage 50000 70568 ns/op 7 | BenchmarkMessengerSendMediumMessage 50000 70265 ns/op 8 | BenchmarkMessengerSendBigMessage 50000 72693 ns/op 9 | BenchmarkMessengerSendLargeMessage 50000 72896 ns/op 10 | BenchmarkMessengerSendMixedMessage 50000 72631 ns/op 11 | BenchmarkMessengerSendRecvSmallMessage 20000 78409 ns/op 12 | BenchmarkMessengerSendRecvMediumMessage 20000 80471 ns/op 13 | BenchmarkMessengerSendRecvBigMessage 20000 82629 ns/op 14 | BenchmarkMessengerSendRecvLargeMessage 20000 85987 ns/op 15 | BenchmarkMessengerSendRecvMixedMessage 20000 83678 ns/op 16 | ok github.com/mesos/mesos-go/messenger 115.135s 17 | 18 | $ go test -v -run=Benckmark* -bench=. -cpu=4 -send-routines=4 2>/dev/null 19 | PASS 20 | BenchmarkMessengerSendSmallMessage-4 50000 35529 ns/op 21 | BenchmarkMessengerSendMediumMessage-4 50000 35997 ns/op 22 | BenchmarkMessengerSendBigMessage-4 50000 36871 ns/op 23 | BenchmarkMessengerSendLargeMessage-4 50000 37310 ns/op 24 | BenchmarkMessengerSendMixedMessage-4 50000 37419 ns/op 25 | BenchmarkMessengerSendRecvSmallMessage-4 50000 39320 ns/op 26 | BenchmarkMessengerSendRecvMediumMessage-4 50000 41990 ns/op 27 | BenchmarkMessengerSendRecvBigMessage-4 50000 42157 ns/op 28 | BenchmarkMessengerSendRecvLargeMessage-4 50000 45472 ns/op 29 | BenchmarkMessengerSendRecvMixedMessage-4 50000 47393 ns/op 30 | ok github.com/mesos/mesos-go/messenger 105.173s 31 | ``` 32 | 33 | ####environment: 34 | 35 | ``` 36 | OS: Linux yifan-laptop 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux 37 | CPU: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz 38 | MEM: 4G DDR3 1600MHz 39 | ``` 40 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/httpexec/httpexec_generated.go: -------------------------------------------------------------------------------- 1 | package httpexec 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/executor -import github.com/mesos/mesos-go/api/v1/lib/executor/calls -type C:executor.Call:executor.Call{Type:executor.Call_MESSAGE} 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | 9 | "github.com/mesos/mesos-go/api/v1/lib" 10 | "github.com/mesos/mesos-go/api/v1/lib/client" 11 | "github.com/mesos/mesos-go/api/v1/lib/httpcli" 12 | 13 | "github.com/mesos/mesos-go/api/v1/lib/executor" 14 | "github.com/mesos/mesos-go/api/v1/lib/executor/calls" 15 | ) 16 | 17 | // ResponseClassifier determines the appropriate response class for the given call. 18 | type ResponseClassifier func(*executor.Call) (client.ResponseClass, error) 19 | 20 | // ClientFunc sends a Request to Mesos and returns the generated Response. 21 | type ClientFunc func(client.Request, client.ResponseClass, ...httpcli.RequestOpt) (mesos.Response, error) 22 | 23 | // DefaultResponseClassifier is a pluggable classifier. 24 | var DefaultResponseClassifier = ResponseClassifier(classifyResponse) 25 | 26 | // NewSender generates a sender that uses the Mesos v1 HTTP API for encoding/decoding requests/responses. 27 | // The ResponseClass is inferred from the first object generated by the given Request. 28 | func NewSender(cf ClientFunc, ro ...httpcli.RequestOpt) calls.Sender { 29 | return calls.SenderFunc(func(ctx context.Context, r calls.Request) (mesos.Response, error) { 30 | var ( 31 | obj = r.Call() 32 | rc, err = DefaultResponseClassifier(obj) 33 | ) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | var req client.Request 39 | 40 | switch r := r.(type) { 41 | case calls.RequestStreaming: 42 | req = calls.Push(r, obj) 43 | default: 44 | req = calls.NonStreaming(obj) 45 | } 46 | 47 | return cf(req, rc, append(ro, httpcli.Context(ctx))...) 48 | }) 49 | } 50 | -------------------------------------------------------------------------------- /api/v1/lib/extras/executor/eventrules/metrics_generated_test.go: -------------------------------------------------------------------------------- 1 | package eventrules 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/executor -type E:*executor.Event:&executor.Event{} -type ET:executor.Event_Type -output metrics_generated.go 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | "errors" 9 | "reflect" 10 | "testing" 11 | 12 | "github.com/mesos/mesos-go/api/v1/lib/executor" 13 | ) 14 | 15 | func TestMetrics(t *testing.T) { 16 | var ( 17 | i int 18 | ctx = context.Background() 19 | p = &executor.Event{} 20 | a = errors.New("a") 21 | h = func(f func() error, _ ...string) error { 22 | i++ 23 | return f() 24 | } 25 | ) 26 | for ti, tc := range []struct { 27 | ctx context.Context 28 | e *executor.Event 29 | err error 30 | }{ 31 | {ctx, p, a}, 32 | {ctx, p, nil}, 33 | {ctx, nil, a}, 34 | } { 35 | for ri, r := range []Rule{ 36 | Metrics(h, nil), // default labeler 37 | Metrics(h, func(_ context.Context, _ *executor.Event) []string { return nil }), // custom labeler 38 | } { 39 | c, e, err := r.Eval(tc.ctx, tc.e, tc.err, ChainIdentity) 40 | if !reflect.DeepEqual(c, tc.ctx) { 41 | t.Errorf("test case %d: expected context %q instead of %q", ti, tc.ctx, c) 42 | } 43 | if !reflect.DeepEqual(e, tc.e) { 44 | t.Errorf("test case %d: expected event %q instead of %q", ti, tc.e, e) 45 | } 46 | if !reflect.DeepEqual(err, tc.err) { 47 | t.Errorf("test case %d: expected error %q instead of %q", ti, tc.err, err) 48 | } 49 | if y := (ti * 2) + ri + 1; y != i { 50 | t.Errorf("test case %d: expected count %q instead of %q", ti, y, i) 51 | } 52 | } 53 | } 54 | func() { 55 | defer func() { 56 | if x := recover(); x != nil { 57 | t.Log("intercepted expected panic", x) 58 | } 59 | }() 60 | _ = Metrics(nil, nil) 61 | t.Fatalf("expected a panic because nil harness is not allowed") 62 | }() 63 | } 64 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/pborman/uuid/hash.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "crypto/md5" 9 | "crypto/sha1" 10 | "hash" 11 | ) 12 | 13 | // Well known Name Space IDs and UUIDs 14 | var ( 15 | NameSpace_DNS = Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8") 16 | NameSpace_URL = Parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8") 17 | NameSpace_OID = Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8") 18 | NameSpace_X500 = Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8") 19 | NIL = Parse("00000000-0000-0000-0000-000000000000") 20 | ) 21 | 22 | // NewHash returns a new UUID dervied from the hash of space concatenated with 23 | // data generated by h. The hash should be at least 16 byte in length. The 24 | // first 16 bytes of the hash are used to form the UUID. The version of the 25 | // UUID will be the lower 4 bits of version. NewHash is used to implement 26 | // NewMD5 and NewSHA1. 27 | func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID { 28 | h.Reset() 29 | h.Write(space) 30 | h.Write([]byte(data)) 31 | s := h.Sum(nil) 32 | uuid := make([]byte, 16) 33 | copy(uuid, s) 34 | uuid[6] = (uuid[6] & 0x0f) | uint8((version&0xf)<<4) 35 | uuid[8] = (uuid[8] & 0x3f) | 0x80 // RFC 4122 variant 36 | return uuid 37 | } 38 | 39 | // NewMD5 returns a new MD5 (Version 3) UUID based on the 40 | // supplied name space and data. 41 | // 42 | // NewHash(md5.New(), space, data, 3) 43 | func NewMD5(space UUID, data []byte) UUID { 44 | return NewHash(md5.New(), space, data, 3) 45 | } 46 | 47 | // NewSHA1 returns a new SHA1 (Version 5) UUID based on the 48 | // supplied name space and data. 49 | // 50 | // NewHash(sha1.New(), space, data, 5) 51 | func NewSHA1(space UUID, data []byte) UUID { 52 | return NewHash(sha1.New(), space, data, 5) 53 | } 54 | -------------------------------------------------------------------------------- /api/v1/lib/extras/scheduler/eventrules/metrics_generated_test.go: -------------------------------------------------------------------------------- 1 | package eventrules 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/scheduler -type E:*scheduler.Event:&scheduler.Event{} -type ET:scheduler.Event_Type -output metrics_generated.go 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | "errors" 9 | "reflect" 10 | "testing" 11 | 12 | "github.com/mesos/mesos-go/api/v1/lib/scheduler" 13 | ) 14 | 15 | func TestMetrics(t *testing.T) { 16 | var ( 17 | i int 18 | ctx = context.Background() 19 | p = &scheduler.Event{} 20 | a = errors.New("a") 21 | h = func(f func() error, _ ...string) error { 22 | i++ 23 | return f() 24 | } 25 | ) 26 | for ti, tc := range []struct { 27 | ctx context.Context 28 | e *scheduler.Event 29 | err error 30 | }{ 31 | {ctx, p, a}, 32 | {ctx, p, nil}, 33 | {ctx, nil, a}, 34 | } { 35 | for ri, r := range []Rule{ 36 | Metrics(h, nil), // default labeler 37 | Metrics(h, func(_ context.Context, _ *scheduler.Event) []string { return nil }), // custom labeler 38 | } { 39 | c, e, err := r.Eval(tc.ctx, tc.e, tc.err, ChainIdentity) 40 | if !reflect.DeepEqual(c, tc.ctx) { 41 | t.Errorf("test case %d: expected context %q instead of %q", ti, tc.ctx, c) 42 | } 43 | if !reflect.DeepEqual(e, tc.e) { 44 | t.Errorf("test case %d: expected event %q instead of %q", ti, tc.e, e) 45 | } 46 | if !reflect.DeepEqual(err, tc.err) { 47 | t.Errorf("test case %d: expected error %q instead of %q", ti, tc.err, err) 48 | } 49 | if y := (ti * 2) + ri + 1; y != i { 50 | t.Errorf("test case %d: expected count %q instead of %q", ti, y, i) 51 | } 52 | } 53 | } 54 | func() { 55 | defer func() { 56 | if x := recover(); x != nil { 57 | t.Log("intercepted expected panic", x) 58 | } 59 | }() 60 | _ = Metrics(nil, nil) 61 | t.Fatalf("expected a panic because nil harness is not allowed") 62 | }() 63 | } 64 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/httpagent/util.go: -------------------------------------------------------------------------------- 1 | package httpagent 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/mesos/mesos-go/api/v1/lib/agent" 7 | "github.com/mesos/mesos-go/api/v1/lib/client" 8 | "github.com/mesos/mesos-go/api/v1/lib/httpcli" 9 | ) 10 | 11 | func classifyResponse(c *agent.Call) (rc client.ResponseClass, err error) { 12 | if c == nil { 13 | err = httpcli.ProtocolError("nil agent.Call not allowed") 14 | return 15 | } 16 | 17 | switch t := c.GetType(); t { 18 | // singleton 19 | case agent.Call_GET_HEALTH, 20 | agent.Call_GET_FLAGS, 21 | agent.Call_GET_VERSION, 22 | agent.Call_GET_METRICS, 23 | agent.Call_GET_LOGGING_LEVEL, 24 | agent.Call_LIST_FILES, 25 | agent.Call_READ_FILE, 26 | agent.Call_GET_STATE, 27 | agent.Call_GET_CONTAINERS, 28 | agent.Call_GET_FRAMEWORKS, 29 | agent.Call_GET_EXECUTORS, 30 | agent.Call_GET_OPERATIONS, 31 | agent.Call_GET_TASKS, 32 | agent.Call_GET_AGENT, 33 | agent.Call_GET_RESOURCE_PROVIDERS, 34 | agent.Call_WAIT_CONTAINER, 35 | agent.Call_WAIT_NESTED_CONTAINER: 36 | rc = client.ResponseClassSingleton 37 | 38 | // streaming 39 | case agent.Call_LAUNCH_NESTED_CONTAINER_SESSION, 40 | agent.Call_ATTACH_CONTAINER_OUTPUT: 41 | rc = client.ResponseClassStreaming 42 | 43 | // no-data 44 | case agent.Call_SET_LOGGING_LEVEL, 45 | agent.Call_LAUNCH_CONTAINER, 46 | agent.Call_LAUNCH_NESTED_CONTAINER, 47 | agent.Call_KILL_CONTAINER, 48 | agent.Call_KILL_NESTED_CONTAINER, 49 | agent.Call_REMOVE_CONTAINER, 50 | agent.Call_REMOVE_NESTED_CONTAINER, 51 | agent.Call_ATTACH_CONTAINER_INPUT, 52 | agent.Call_ADD_RESOURCE_PROVIDER_CONFIG, 53 | agent.Call_UPDATE_RESOURCE_PROVIDER_CONFIG, 54 | agent.Call_REMOVE_RESOURCE_PROVIDER_CONFIG, 55 | agent.Call_PRUNE_IMAGES, 56 | agent.Call_MARK_RESOURCE_PROVIDER_GONE: 57 | rc = client.ResponseClassNoData 58 | 59 | default: 60 | err = httpcli.ProtocolError(fmt.Sprintf("unsupported agent.Call type: %v", t)) 61 | } 62 | return 63 | } 64 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/httpagent/httpagent_generated_test.go: -------------------------------------------------------------------------------- 1 | package httpagent 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/agent -import github.com/mesos/mesos-go/api/v1/lib/agent/calls -type C:agent.Call:agent.Call{Type:agent.Call_GET_METRICS} 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | "testing" 9 | 10 | "github.com/mesos/mesos-go/api/v1/lib" 11 | "github.com/mesos/mesos-go/api/v1/lib/client" 12 | "github.com/mesos/mesos-go/api/v1/lib/httpcli" 13 | 14 | "github.com/mesos/mesos-go/api/v1/lib/agent" 15 | "github.com/mesos/mesos-go/api/v1/lib/agent/calls" 16 | ) 17 | 18 | func TestNewSender(t *testing.T) { 19 | ch := make(chan client.Request, 1) 20 | cf := ClientFunc(func(r client.Request, _ client.ResponseClass, _ ...httpcli.RequestOpt) (_ mesos.Response, _ error) { 21 | ch <- r 22 | return 23 | }) 24 | check := func(_ mesos.Response, err error) { 25 | if err != nil { 26 | t.Fatal(err) 27 | } 28 | } 29 | sent := func() client.Request { 30 | select { 31 | case r := <-ch: 32 | return r 33 | default: 34 | t.Fatal("no request was sent") 35 | } 36 | return nil 37 | } 38 | sender := NewSender(cf) 39 | c := &agent.Call{Type:agent.Call_GET_METRICS} 40 | 41 | check(sender.Send(context.Background(), calls.NonStreaming(c))) 42 | r := sent() 43 | if _, ok := r.(client.RequestStreaming); ok { 44 | t.Fatalf("expected non-streaming request instead of %v", r) 45 | } 46 | 47 | check(sender.Send(context.Background(), calls.Empty().Push(c))) 48 | r = sent() 49 | if _, ok := r.(client.RequestStreaming); !ok { 50 | t.Fatalf("expected streaming request instead of %v", r) 51 | } 52 | 53 | // expect this to fail because newly created call structs don't have a type 54 | // that can be used for classifying an expected response type. 55 | _, err := sender.Send(context.Background(), calls.Empty().Push(new(agent.Call))) 56 | if err == nil { 57 | t.Fatal("expected send to fail w/ malformed call") 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/golang.org/x/net/context/ctxhttp/ctxhttp_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ctxhttp 6 | 7 | import ( 8 | "io/ioutil" 9 | "net/http" 10 | "net/http/httptest" 11 | "testing" 12 | "time" 13 | 14 | "golang.org/x/net/context" 15 | ) 16 | 17 | const ( 18 | requestDuration = 100 * time.Millisecond 19 | requestBody = "ok" 20 | ) 21 | 22 | func TestNoTimeout(t *testing.T) { 23 | ctx := context.Background() 24 | resp, err := doRequest(ctx) 25 | 26 | if resp == nil || err != nil { 27 | t.Fatalf("error received from client: %v %v", err, resp) 28 | } 29 | } 30 | func TestCancel(t *testing.T) { 31 | ctx, cancel := context.WithCancel(context.Background()) 32 | go func() { 33 | time.Sleep(requestDuration / 2) 34 | cancel() 35 | }() 36 | 37 | resp, err := doRequest(ctx) 38 | 39 | if resp != nil || err == nil { 40 | t.Fatalf("expected error, didn't get one. resp: %v", resp) 41 | } 42 | if err != ctx.Err() { 43 | t.Fatalf("expected error from context but got: %v", err) 44 | } 45 | } 46 | 47 | func TestCancelAfterRequest(t *testing.T) { 48 | ctx, cancel := context.WithCancel(context.Background()) 49 | 50 | resp, err := doRequest(ctx) 51 | 52 | // Cancel before reading the body. 53 | // Request.Body should still be readable after the context is canceled. 54 | cancel() 55 | 56 | b, err := ioutil.ReadAll(resp.Body) 57 | if err != nil || string(b) != requestBody { 58 | t.Fatalf("could not read body: %q %v", b, err) 59 | } 60 | } 61 | 62 | func doRequest(ctx context.Context) (*http.Response, error) { 63 | var okHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 64 | time.Sleep(requestDuration) 65 | w.Write([]byte(requestBody)) 66 | }) 67 | 68 | serv := httptest.NewServer(okHandler) 69 | defer serv.Close() 70 | 71 | return Get(ctx, nil, serv.URL) 72 | } 73 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/gogo/protobuf/proto/testdata/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | all: regenerate 33 | 34 | regenerate: 35 | go install github.com/gogo/protobuf/protoc-min-version 36 | protoc-min-version --version="3.0.0" --gogo_out=. test.proto 37 | 38 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/apierrors/apierrors_test.go: -------------------------------------------------------------------------------- 1 | package apierrors 2 | 3 | import ( 4 | "bytes" 5 | "io/ioutil" 6 | "net/http" 7 | "reflect" 8 | "testing" 9 | ) 10 | 11 | func TestFromResponse(t *testing.T) { 12 | for _, tt := range []struct { 13 | r *http.Response 14 | e error 15 | }{ 16 | {nil, nil}, 17 | { 18 | &http.Response{StatusCode: 200}, 19 | nil, 20 | }, 21 | { 22 | &http.Response{StatusCode: 400, Body: ioutil.NopCloser(bytes.NewBufferString("missing framework id"))}, 23 | &Error{400, ErrorTable[CodeMalformedRequest] + ": missing framework id"}, 24 | }, 25 | } { 26 | rr := FromResponse(tt.r) 27 | if !reflect.DeepEqual(tt.e, rr) { 28 | t.Errorf("Expected: %v, got: %v", tt.e, rr) 29 | } 30 | } 31 | } 32 | 33 | func TestError(t *testing.T) { 34 | for _, tt := range []struct { 35 | code Code 36 | isErr bool 37 | details string 38 | wantsMessage string 39 | temporary bool 40 | subscriptionLoss bool 41 | }{ 42 | {200, false, "", "", false, false}, 43 | {400, true, "", "malformed request", false, false}, 44 | {400, true, "foo", "malformed request: foo", false, false}, 45 | } { 46 | err := tt.code.Error(tt.details) 47 | if !tt.code.Matches(err) { 48 | t.Errorf("expected expected code %v to match that of the error %q", tt.code, err) 49 | } 50 | if tt.isErr != (err != nil) { 51 | t.Errorf("expected isErr %v but error was %q", tt.isErr, err) 52 | } 53 | if err != nil { 54 | if err.Error() != tt.wantsMessage { 55 | t.Errorf("Expected: %s, got: %s", tt.wantsMessage, err.Error()) 56 | } 57 | apierr := err.(*Error) 58 | if apierr.Temporary() != tt.temporary { 59 | t.Errorf("expected temporary to be %v instead of %v", tt.temporary, apierr.Temporary()) 60 | } 61 | if apierr.SubscriptionLoss() != tt.subscriptionLoss { 62 | t.Errorf("expected subscription-loss to be %v instead of %v", tt.subscriptionLoss, apierr.SubscriptionLoss()) 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/httpmaster/httpmaster_generated_test.go: -------------------------------------------------------------------------------- 1 | package httpmaster 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/master -import github.com/mesos/mesos-go/api/v1/lib/master/calls -type C:master.Call:master.Call{Type:master.Call_GET_METRICS} 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | "testing" 9 | 10 | "github.com/mesos/mesos-go/api/v1/lib" 11 | "github.com/mesos/mesos-go/api/v1/lib/client" 12 | "github.com/mesos/mesos-go/api/v1/lib/httpcli" 13 | 14 | "github.com/mesos/mesos-go/api/v1/lib/master" 15 | "github.com/mesos/mesos-go/api/v1/lib/master/calls" 16 | ) 17 | 18 | func TestNewSender(t *testing.T) { 19 | ch := make(chan client.Request, 1) 20 | cf := ClientFunc(func(r client.Request, _ client.ResponseClass, _ ...httpcli.RequestOpt) (_ mesos.Response, _ error) { 21 | ch <- r 22 | return 23 | }) 24 | check := func(_ mesos.Response, err error) { 25 | if err != nil { 26 | t.Fatal(err) 27 | } 28 | } 29 | sent := func() client.Request { 30 | select { 31 | case r := <-ch: 32 | return r 33 | default: 34 | t.Fatal("no request was sent") 35 | } 36 | return nil 37 | } 38 | sender := NewSender(cf) 39 | c := &master.Call{Type:master.Call_GET_METRICS} 40 | 41 | check(sender.Send(context.Background(), calls.NonStreaming(c))) 42 | r := sent() 43 | if _, ok := r.(client.RequestStreaming); ok { 44 | t.Fatalf("expected non-streaming request instead of %v", r) 45 | } 46 | 47 | check(sender.Send(context.Background(), calls.Empty().Push(c))) 48 | r = sent() 49 | if _, ok := r.(client.RequestStreaming); !ok { 50 | t.Fatalf("expected streaming request instead of %v", r) 51 | } 52 | 53 | // expect this to fail because newly created call structs don't have a type 54 | // that can be used for classifying an expected response type. 55 | _, err := sender.Send(context.Background(), calls.Empty().Push(new(master.Call))) 56 | if err == nil { 57 | t.Fatal("expected send to fail w/ malformed call") 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /api/v1/lib/resources/find.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "github.com/mesos/mesos-go/api/v1/lib" 5 | "github.com/mesos/mesos-go/api/v1/lib/resourcefilters" 6 | ) 7 | 8 | func Find(wants mesos.Resources, from ...mesos.Resource) (total mesos.Resources) { 9 | for i := range wants { 10 | found := find(wants[i], from...) 11 | 12 | // each want *must* be found 13 | if len(found) == 0 { 14 | return nil 15 | } 16 | 17 | total.Add(found...) 18 | } 19 | return total 20 | } 21 | 22 | func find(want mesos.Resource, from ...mesos.Resource) mesos.Resources { 23 | var ( 24 | total = mesos.Resources(from).Clone() 25 | remaining = mesos.Resources{want}.ToUnreserved() 26 | found mesos.Resources 27 | predicates = resourcefilters.Filters{} 28 | ) 29 | if want.IsReserved("") { 30 | predicates = append(predicates, resourcefilters.ReservedByRole(want.ReservationRole())) 31 | } 32 | predicates = append(predicates, resourcefilters.Unreserved, resourcefilters.Any) 33 | for _, predicate := range predicates { 34 | filtered := resourcefilters.Select(predicate, total...) 35 | for i := range filtered { 36 | // ToUnreserved in order to ignore roles in contains() 37 | unreserved := mesos.Resources{filtered[i]}.ToUnreserved() 38 | if ContainsAll(unreserved, remaining) { 39 | // want has been found, return the result 40 | for j := range remaining { 41 | r := remaining[j] 42 | // assume that the caller isn't mixing pre- and post-reservation 43 | // refinement strategies: that all resources either use one format 44 | // or the other. 45 | r.Role = filtered[i].Role 46 | r.Reservation = filtered[i].Reservation 47 | r.Reservations = filtered[i].Reservations 48 | found.Add1(r) 49 | } 50 | return found 51 | } else if ContainsAll(remaining, unreserved) { 52 | found.Add1(filtered[i]) 53 | total.Subtract1(filtered[i]) 54 | remaining.Subtract(unreserved...) 55 | break 56 | } 57 | } 58 | } 59 | return nil 60 | } 61 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/httpexec/httpexec_generated_test.go: -------------------------------------------------------------------------------- 1 | package httpexec 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/executor -import github.com/mesos/mesos-go/api/v1/lib/executor/calls -type C:executor.Call:executor.Call{Type:executor.Call_MESSAGE} 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | "testing" 9 | 10 | "github.com/mesos/mesos-go/api/v1/lib" 11 | "github.com/mesos/mesos-go/api/v1/lib/client" 12 | "github.com/mesos/mesos-go/api/v1/lib/httpcli" 13 | 14 | "github.com/mesos/mesos-go/api/v1/lib/executor" 15 | "github.com/mesos/mesos-go/api/v1/lib/executor/calls" 16 | ) 17 | 18 | func TestNewSender(t *testing.T) { 19 | ch := make(chan client.Request, 1) 20 | cf := ClientFunc(func(r client.Request, _ client.ResponseClass, _ ...httpcli.RequestOpt) (_ mesos.Response, _ error) { 21 | ch <- r 22 | return 23 | }) 24 | check := func(_ mesos.Response, err error) { 25 | if err != nil { 26 | t.Fatal(err) 27 | } 28 | } 29 | sent := func() client.Request { 30 | select { 31 | case r := <-ch: 32 | return r 33 | default: 34 | t.Fatal("no request was sent") 35 | } 36 | return nil 37 | } 38 | sender := NewSender(cf) 39 | c := &executor.Call{Type:executor.Call_MESSAGE} 40 | 41 | check(sender.Send(context.Background(), calls.NonStreaming(c))) 42 | r := sent() 43 | if _, ok := r.(client.RequestStreaming); ok { 44 | t.Fatalf("expected non-streaming request instead of %v", r) 45 | } 46 | 47 | check(sender.Send(context.Background(), calls.Empty().Push(c))) 48 | r = sent() 49 | if _, ok := r.(client.RequestStreaming); !ok { 50 | t.Fatalf("expected streaming request instead of %v", r) 51 | } 52 | 53 | // expect this to fail because newly created call structs don't have a type 54 | // that can be used for classifying an expected response type. 55 | _, err := sender.Send(context.Background(), calls.Empty().Push(new(executor.Call))) 56 | if err == nil { 57 | t.Fatal("expected send to fail w/ malformed call") 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /api/v0/upid/upid.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package upid 20 | 21 | import ( 22 | "fmt" 23 | "net" 24 | "strings" 25 | ) 26 | 27 | // UPID is a equivalent of the UPID in libprocess. 28 | type UPID struct { 29 | ID string 30 | Host string 31 | Port string 32 | } 33 | 34 | // Parse parses the UPID from the input string. 35 | func Parse(input string) (*UPID, error) { 36 | upid := new(UPID) 37 | 38 | splits := strings.Split(input, "@") 39 | if len(splits) != 2 { 40 | return nil, fmt.Errorf("Expect one `@' in the input") 41 | } 42 | upid.ID = splits[0] 43 | 44 | if _, err := net.ResolveTCPAddr("tcp4", splits[1]); err != nil { 45 | return nil, err 46 | } 47 | upid.Host, upid.Port, _ = net.SplitHostPort(splits[1]) 48 | return upid, nil 49 | } 50 | 51 | // String returns the string representation. 52 | func (u UPID) String() string { 53 | return fmt.Sprintf("%s@%s:%s", u.ID, u.Host, u.Port) 54 | } 55 | 56 | // Equal returns true if two upid is equal 57 | func (u *UPID) Equal(upid *UPID) bool { 58 | if u == nil { 59 | return upid == nil 60 | } else { 61 | return upid != nil && u.ID == upid.ID && u.Host == upid.Host && u.Port == upid.Port 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /api/v1/lib/client/client.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/mesos/mesos-go/api/v1/lib/encoding" 5 | ) 6 | 7 | type ( 8 | // ResponseClass indicates the kind of response that a caller is expecting from Mesos. 9 | ResponseClass int 10 | 11 | // Request is a non-streaming request from the client to the server. 12 | // Marshaler always returns the same object; the object is sent once to the server and then 13 | // a response is expected. 14 | Request interface { 15 | Marshaler() encoding.Marshaler 16 | } 17 | 18 | // RequestStreaming is a streaming request from the client to the server. 19 | // Marshaler returns a new object for upon each invocation, nil when there are no more objects to send. 20 | // Client implementations are expected to differentiate between Request and RequestStreaming either by 21 | // type-switching or by attempting interface conversion. 22 | RequestStreaming interface { 23 | Request 24 | IsStreaming() 25 | } 26 | 27 | RequestFunc func() encoding.Marshaler 28 | RequestStreamingFunc func() encoding.Marshaler 29 | ) 30 | 31 | var ( 32 | _ = Request(RequestFunc(nil)) 33 | _ = RequestStreaming(RequestStreamingFunc(nil)) 34 | ) 35 | 36 | func (f RequestFunc) Marshaler() encoding.Marshaler { return f() } 37 | func (f RequestStreamingFunc) Marshaler() encoding.Marshaler { return f() } 38 | func (f RequestStreamingFunc) IsStreaming() {} 39 | 40 | // RequestSingleton generates a non-streaming Request that always returns the same marshaler 41 | func RequestSingleton(m encoding.Marshaler) Request { 42 | return RequestFunc(func() encoding.Marshaler { return m }) 43 | } 44 | 45 | const ( 46 | ResponseClassSingleton ResponseClass = iota 47 | ResponseClassStreaming 48 | ResponseClassNoData 49 | 50 | // ResponseClassAuto should be used with versions of Mesos prior to 1.2.x. 51 | // Otherwise, this type is deprecated and callers should use ResponseClassSingleton 52 | // or ResponseClassStreaming instead. 53 | ResponseClassAuto 54 | ) 55 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/conversions_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestConversionJSON(t *testing.T) { 9 | 10 | jsonString := `{"name":"Mat"}` 11 | o := MustFromJSON(jsonString) 12 | 13 | result, err := o.JSON() 14 | 15 | if assert.NoError(t, err) { 16 | assert.Equal(t, jsonString, result) 17 | } 18 | 19 | assert.Equal(t, jsonString, o.MustJSON()) 20 | 21 | } 22 | 23 | func TestConversionJSONWithError(t *testing.T) { 24 | 25 | o := MSI() 26 | o["test"] = func() {} 27 | 28 | assert.Panics(t, func() { 29 | o.MustJSON() 30 | }) 31 | 32 | _, err := o.JSON() 33 | 34 | assert.Error(t, err) 35 | 36 | } 37 | 38 | func TestConversionBase64(t *testing.T) { 39 | 40 | o := New(map[string]interface{}{"name": "Mat"}) 41 | 42 | result, err := o.Base64() 43 | 44 | if assert.NoError(t, err) { 45 | assert.Equal(t, "eyJuYW1lIjoiTWF0In0=", result) 46 | } 47 | 48 | assert.Equal(t, "eyJuYW1lIjoiTWF0In0=", o.MustBase64()) 49 | 50 | } 51 | 52 | func TestConversionBase64WithError(t *testing.T) { 53 | 54 | o := MSI() 55 | o["test"] = func() {} 56 | 57 | assert.Panics(t, func() { 58 | o.MustBase64() 59 | }) 60 | 61 | _, err := o.Base64() 62 | 63 | assert.Error(t, err) 64 | 65 | } 66 | 67 | func TestConversionSignedBase64(t *testing.T) { 68 | 69 | o := New(map[string]interface{}{"name": "Mat"}) 70 | 71 | result, err := o.SignedBase64("key") 72 | 73 | if assert.NoError(t, err) { 74 | assert.Equal(t, "eyJuYW1lIjoiTWF0In0=_67ee82916f90b2c0d68c903266e8998c9ef0c3d6", result) 75 | } 76 | 77 | assert.Equal(t, "eyJuYW1lIjoiTWF0In0=_67ee82916f90b2c0d68c903266e8998c9ef0c3d6", o.MustSignedBase64("key")) 78 | 79 | } 80 | 81 | func TestConversionSignedBase64WithError(t *testing.T) { 82 | 83 | o := MSI() 84 | o["test"] = func() {} 85 | 86 | assert.Panics(t, func() { 87 | o.MustSignedBase64("key") 88 | }) 89 | 90 | _, err := o.SignedBase64("key") 91 | 92 | assert.Error(t, err) 93 | 94 | } 95 | -------------------------------------------------------------------------------- /api/v0/detector/zoo/client2.go: -------------------------------------------------------------------------------- 1 | package zoo 2 | 3 | import ( 4 | "sync" 5 | "time" 6 | 7 | "github.com/samuel/go-zookeeper/zk" 8 | ) 9 | 10 | const ( 11 | defaultSessionTimeout = 60 * time.Second 12 | CurrentPath = "." 13 | ) 14 | 15 | var zkSessionTimeout = defaultSessionTimeout 16 | 17 | type client2 struct { 18 | *zk.Conn 19 | path string 20 | done chan struct{} // signal chan, closes when the underlying connection terminates 21 | stopOnce sync.Once 22 | } 23 | 24 | func connect2(hosts []string, path string) (*client2, error) { 25 | c, ev, err := zk.Connect(hosts, zkSessionTimeout) 26 | if err != nil { 27 | return nil, err 28 | } 29 | done := make(chan struct{}) 30 | go func() { 31 | // close the 'done' chan when the zk event chan closes (signals termination of zk connection) 32 | defer close(done) 33 | for { 34 | if _, ok := <-ev; !ok { 35 | return 36 | } 37 | } 38 | }() 39 | return &client2{ 40 | Conn: c, 41 | path: path, 42 | done: done, 43 | }, nil 44 | } 45 | 46 | func (c *client2) Stopped() <-chan struct{} { 47 | return c.done 48 | } 49 | 50 | func (c *client2) Stop() { 51 | c.stopOnce.Do(c.Close) 52 | } 53 | 54 | func (c *client2) Data(path string) (data []byte, err error) { 55 | data, _, err = c.Get(path) 56 | return 57 | } 58 | 59 | func (c *client2) WatchChildren(path string) (string, <-chan []string, <-chan error) { 60 | errCh := make(chan error, 1) 61 | snap := make(chan []string) 62 | 63 | watchPath := c.path 64 | if path != "" && path != CurrentPath { 65 | watchPath = watchPath + path 66 | } 67 | go func() { 68 | defer close(errCh) 69 | for { 70 | children, _, ev, err := c.ChildrenW(watchPath) 71 | if err != nil { 72 | errCh <- err 73 | return 74 | } 75 | select { 76 | case snap <- children: 77 | case <-c.done: 78 | return 79 | } 80 | e := <-ev // wait for the next watch-related event 81 | if e.Err != nil { 82 | errCh <- e.Err 83 | return 84 | } 85 | } 86 | }() 87 | return watchPath, snap, errCh 88 | } 89 | -------------------------------------------------------------------------------- /api/v1/lib/resources/compare.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "github.com/gogo/protobuf/proto" 5 | "github.com/mesos/mesos-go/api/v1/lib" 6 | ) 7 | 8 | func Validate(resources ...mesos.Resource) error { 9 | type withSpec interface { 10 | WithSpec(mesos.Resource) 11 | } 12 | for i := range resources { 13 | err := resources[i].Validate() 14 | if err != nil { 15 | // augment resourceError's with the resource that failed to validate 16 | if resourceError, ok := err.(withSpec); ok { 17 | r := proto.Clone(&resources[i]).(*mesos.Resource) 18 | resourceError.WithSpec(*r) 19 | } 20 | return err 21 | } 22 | } 23 | return nil 24 | } 25 | 26 | func Equivalent(subject, that []mesos.Resource) bool { 27 | return ContainsAll(subject, that) && ContainsAll(that, subject) 28 | } 29 | 30 | func Contains(subject []mesos.Resource, that mesos.Resource) bool { 31 | // NOTE: We must validate 'that' because invalid resources can lead 32 | // to false positives here (e.g., "cpus:-1" will return true). This 33 | // is because 'contains' assumes resources are valid. 34 | return that.Validate() == nil && contains(subject, that) 35 | } 36 | 37 | func contains(subject []mesos.Resource, that mesos.Resource) bool { 38 | // TODO(jdef): take into account the "count" of shared resources 39 | for i := range subject { 40 | if subject[i].Contains(that) { 41 | return true 42 | } 43 | } 44 | return false 45 | } 46 | 47 | // ContainsAll returns true if this set of resources contains that set of (presumably pre-validated) resources. 48 | func ContainsAll(subject, that []mesos.Resource) bool { 49 | remaining := mesos.Resources(subject).Clone() 50 | for i := range that { 51 | // NOTE: We use contains() because resources only contain valid 52 | // Resource objects, and we don't want the performance hit of the 53 | // validity check. 54 | if !contains(remaining, that[i]) { 55 | return false 56 | } 57 | if that[i].GetDisk().GetPersistence() != nil { 58 | remaining.Subtract1(that[i]) 59 | } 60 | } 61 | return true 62 | } 63 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/stretchr/objx/mutations_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestExclude(t *testing.T) { 9 | 10 | d := make(Map) 11 | d["name"] = "Mat" 12 | d["age"] = 29 13 | d["secret"] = "ABC" 14 | 15 | excluded := d.Exclude([]string{"secret"}) 16 | 17 | assert.Equal(t, d["name"], excluded["name"]) 18 | assert.Equal(t, d["age"], excluded["age"]) 19 | assert.False(t, excluded.Has("secret"), "secret should be excluded") 20 | 21 | } 22 | 23 | func TestCopy(t *testing.T) { 24 | 25 | d1 := make(map[string]interface{}) 26 | d1["name"] = "Tyler" 27 | d1["location"] = "UT" 28 | 29 | d1Obj := New(d1) 30 | d2Obj := d1Obj.Copy() 31 | 32 | d2Obj["name"] = "Mat" 33 | 34 | assert.Equal(t, d1Obj.Get("name").Str(), "Tyler") 35 | assert.Equal(t, d2Obj.Get("name").Str(), "Mat") 36 | 37 | } 38 | 39 | func TestMerge(t *testing.T) { 40 | 41 | d := make(map[string]interface{}) 42 | d["name"] = "Mat" 43 | 44 | d1 := make(map[string]interface{}) 45 | d1["name"] = "Tyler" 46 | d1["location"] = "UT" 47 | 48 | dObj := New(d) 49 | d1Obj := New(d1) 50 | 51 | merged := dObj.Merge(d1Obj) 52 | 53 | assert.Equal(t, merged.Get("name").Str(), d1Obj.Get("name").Str()) 54 | assert.Equal(t, merged.Get("location").Str(), d1Obj.Get("location").Str()) 55 | assert.Empty(t, dObj.Get("location").Str()) 56 | 57 | } 58 | 59 | func TestMergeHere(t *testing.T) { 60 | 61 | d := make(map[string]interface{}) 62 | d["name"] = "Mat" 63 | 64 | d1 := make(map[string]interface{}) 65 | d1["name"] = "Tyler" 66 | d1["location"] = "UT" 67 | 68 | dObj := New(d) 69 | d1Obj := New(d1) 70 | 71 | merged := dObj.MergeHere(d1Obj) 72 | 73 | assert.Equal(t, dObj, merged, "With MergeHere, it should return the first modified map") 74 | assert.Equal(t, merged.Get("name").Str(), d1Obj.Get("name").Str()) 75 | assert.Equal(t, merged.Get("location").Str(), d1Obj.Get("location").Str()) 76 | assert.Equal(t, merged.Get("location").Str(), dObj.Get("location").Str()) 77 | } 78 | -------------------------------------------------------------------------------- /api/v1/lib/extras/executor/callrules/callers_generated.go: -------------------------------------------------------------------------------- 1 | package callrules 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/executor -import github.com/mesos/mesos-go/api/v1/lib/executor/calls -type E:*executor.Call -type C:calls.Caller -type CF:calls.CallerFunc -output callers_generated.go 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | 9 | "github.com/mesos/mesos-go/api/v1/lib" 10 | 11 | "github.com/mesos/mesos-go/api/v1/lib/executor" 12 | "github.com/mesos/mesos-go/api/v1/lib/executor/calls" 13 | ) 14 | 15 | // Call returns a Rule that invokes the given Caller 16 | func Call(caller calls.Caller) Rule { 17 | if caller == nil { 18 | return nil 19 | } 20 | return func(ctx context.Context, c *executor.Call, _ mesos.Response, _ error, ch Chain) (context.Context, *executor.Call, mesos.Response, error) { 21 | resp, err := caller.Call(ctx, c) 22 | return ch(ctx, c, resp, err) 23 | } 24 | } 25 | 26 | // CallF returns a Rule that invokes the given CallerFunc 27 | func CallF(cf calls.CallerFunc) Rule { 28 | return Call(calls.Caller(cf)) 29 | } 30 | 31 | // Caller returns a Rule that invokes the receiver and then calls the given Caller 32 | func (r Rule) Caller(caller calls.Caller) Rule { 33 | return Rules{r, Call(caller)}.Eval 34 | } 35 | 36 | // CallerF returns a Rule that invokes the receiver and then calls the given CallerFunc 37 | func (r Rule) CallerF(cf calls.CallerFunc) Rule { 38 | return r.Caller(calls.Caller(cf)) 39 | } 40 | 41 | // Call implements the Caller interface for Rule 42 | func (r Rule) Call(ctx context.Context, c *executor.Call) (mesos.Response, error) { 43 | if r == nil { 44 | return nil, nil 45 | } 46 | _, _, resp, err := r(ctx, c, nil, nil, ChainIdentity) 47 | return resp, err 48 | } 49 | 50 | // Call implements the Caller interface for Rules 51 | func (rs Rules) Call(ctx context.Context, c *executor.Call) (mesos.Response, error) { 52 | return Rule(rs.Eval).Call(ctx, c) 53 | } 54 | 55 | var ( 56 | _ = calls.Caller(Rule(nil)) 57 | _ = calls.Caller(Rules(nil)) 58 | ) 59 | -------------------------------------------------------------------------------- /api/v1/lib/extras/scheduler/callrules/callers_generated.go: -------------------------------------------------------------------------------- 1 | package callrules 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib/scheduler -import github.com/mesos/mesos-go/api/v1/lib/scheduler/calls -type E:*scheduler.Call -type C:calls.Caller -type CF:calls.CallerFunc -output callers_generated.go 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | 9 | "github.com/mesos/mesos-go/api/v1/lib" 10 | 11 | "github.com/mesos/mesos-go/api/v1/lib/scheduler" 12 | "github.com/mesos/mesos-go/api/v1/lib/scheduler/calls" 13 | ) 14 | 15 | // Call returns a Rule that invokes the given Caller 16 | func Call(caller calls.Caller) Rule { 17 | if caller == nil { 18 | return nil 19 | } 20 | return func(ctx context.Context, c *scheduler.Call, _ mesos.Response, _ error, ch Chain) (context.Context, *scheduler.Call, mesos.Response, error) { 21 | resp, err := caller.Call(ctx, c) 22 | return ch(ctx, c, resp, err) 23 | } 24 | } 25 | 26 | // CallF returns a Rule that invokes the given CallerFunc 27 | func CallF(cf calls.CallerFunc) Rule { 28 | return Call(calls.Caller(cf)) 29 | } 30 | 31 | // Caller returns a Rule that invokes the receiver and then calls the given Caller 32 | func (r Rule) Caller(caller calls.Caller) Rule { 33 | return Rules{r, Call(caller)}.Eval 34 | } 35 | 36 | // CallerF returns a Rule that invokes the receiver and then calls the given CallerFunc 37 | func (r Rule) CallerF(cf calls.CallerFunc) Rule { 38 | return r.Caller(calls.Caller(cf)) 39 | } 40 | 41 | // Call implements the Caller interface for Rule 42 | func (r Rule) Call(ctx context.Context, c *scheduler.Call) (mesos.Response, error) { 43 | if r == nil { 44 | return nil, nil 45 | } 46 | _, _, resp, err := r(ctx, c, nil, nil, ChainIdentity) 47 | return resp, err 48 | } 49 | 50 | // Call implements the Caller interface for Rules 51 | func (rs Rules) Call(ctx context.Context, c *scheduler.Call) (mesos.Response, error) { 52 | return Rule(rs.Eval).Call(ctx, c) 53 | } 54 | 55 | var ( 56 | _ = calls.Caller(Rule(nil)) 57 | _ = calls.Caller(Rules(nil)) 58 | ) 59 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/gogo/protobuf/proto/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | install: 33 | go install 34 | 35 | test: install generate-test-pbs 36 | go test 37 | 38 | 39 | generate-test-pbs: 40 | make install 41 | make -C testdata 42 | protoc-min-version --version="3.0.0" --proto_path=.:../../../../ --gogo_out=. proto3_proto/proto3.proto 43 | make 44 | -------------------------------------------------------------------------------- /api/v1/lib/extras/gen/rule_callers.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import ( 6 | "os" 7 | "text/template" 8 | ) 9 | 10 | func main() { 11 | Run(handlersTemplate, nil, os.Args...) 12 | } 13 | 14 | var handlersTemplate = template.Must(template.New("").Parse(`package {{.Package}} 15 | 16 | // go generate {{.Args}} 17 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/mesos/mesos-go/api/v1/lib" 23 | {{range .Imports}} 24 | {{ printf "%q" . -}} 25 | {{end}} 26 | ) 27 | 28 | {{.RequireType "E" -}} 29 | {{.RequireType "C" -}} 30 | {{.RequireType "CF" -}} 31 | // Call returns a Rule that invokes the given Caller 32 | func Call(caller {{.Type "C"}}) Rule { 33 | if caller == nil { 34 | return nil 35 | } 36 | return func(ctx context.Context, c {{.Type "E"}}, _ mesos.Response, _ error, ch Chain) (context.Context, {{.Type "E"}}, mesos.Response, error) { 37 | resp, err := caller.Call(ctx, c) 38 | return ch(ctx, c, resp, err) 39 | } 40 | } 41 | 42 | // CallF returns a Rule that invokes the given CallerFunc 43 | func CallF(cf {{.Type "CF"}}) Rule { 44 | return Call({{.Type "C"}}(cf)) 45 | } 46 | 47 | // Caller returns a Rule that invokes the receiver and then calls the given Caller 48 | func (r Rule) Caller(caller {{.Type "C"}}) Rule { 49 | return Rules{r, Call(caller)}.Eval 50 | } 51 | 52 | // CallerF returns a Rule that invokes the receiver and then calls the given CallerFunc 53 | func (r Rule) CallerF(cf {{.Type "CF"}}) Rule { 54 | return r.Caller({{.Type "C"}}(cf)) 55 | } 56 | 57 | // Call implements the Caller interface for Rule 58 | func (r Rule) Call(ctx context.Context, c {{.Type "E"}}) (mesos.Response, error) { 59 | if r == nil { 60 | return nil, nil 61 | } 62 | _, _, resp, err := r(ctx, c, nil, nil, ChainIdentity) 63 | return resp, err 64 | } 65 | 66 | // Call implements the Caller interface for Rules 67 | func (rs Rules) Call(ctx context.Context, c {{.Type "E"}}) (mesos.Response, error) { 68 | return Rule(rs.Eval).Call(ctx, c) 69 | } 70 | 71 | var ( 72 | _ = {{.Type "C"}}(Rule(nil)) 73 | _ = {{.Type "C"}}(Rules(nil)) 74 | ) 75 | `)) 76 | -------------------------------------------------------------------------------- /api/v0/scheduler/testing.go: -------------------------------------------------------------------------------- 1 | package scheduler 2 | 3 | import ( 4 | "github.com/gogo/protobuf/proto" 5 | mesos "github.com/mesos/mesos-go/api/v0/mesosproto" 6 | "github.com/mesos/mesos-go/api/v0/upid" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | type TestDriver struct { 11 | *MesosSchedulerDriver 12 | } 13 | 14 | func (t *TestDriver) SetConnected(b bool) { 15 | t.eventLock.Lock() 16 | defer t.eventLock.Unlock() 17 | t.connected = b 18 | } 19 | 20 | func (t *TestDriver) Started() <-chan struct{} { 21 | return t.started 22 | } 23 | 24 | func (t *TestDriver) Stopped() <-chan struct{} { 25 | return t.stopCh 26 | } 27 | 28 | func (t *TestDriver) Done() <-chan struct{} { 29 | return t.done 30 | } 31 | 32 | func (t *TestDriver) Framework() *mesos.FrameworkInfo { 33 | return t.frameworkInfo 34 | } 35 | 36 | func (t *TestDriver) UPID() *upid.UPID { 37 | return t.self 38 | } 39 | 40 | func (t *TestDriver) MasterPID() *upid.UPID { 41 | return t.masterPid 42 | } 43 | 44 | func (t *TestDriver) Fatal(ctx context.Context, msg string) { 45 | t.eventLock.Lock() 46 | defer t.eventLock.Unlock() 47 | t.fatal(ctx, msg) 48 | } 49 | 50 | func (t *TestDriver) OnDispatch(f func(ctx context.Context, upid *upid.UPID, msg proto.Message) error) { 51 | t.dispatch = f 52 | } 53 | 54 | func (t *TestDriver) HandleMasterChanged(ctx context.Context, from *upid.UPID, msg proto.Message) { 55 | t.eventLock.Lock() 56 | defer t.eventLock.Unlock() 57 | t.handleMasterChanged(ctx, from, msg) 58 | } 59 | 60 | func (t *TestDriver) CacheOffer(offer *mesos.Offer, pid *upid.UPID) { 61 | t.cache.putOffer(offer, pid) 62 | } 63 | 64 | func (t *TestDriver) Context() context.Context { 65 | return t.context() 66 | } 67 | 68 | func (t *TestDriver) FrameworkRegistered(ctx context.Context, from *upid.UPID, msg proto.Message) { 69 | t.eventLock.Lock() 70 | defer t.eventLock.Unlock() 71 | t.frameworkRegistered(ctx, from, msg) 72 | } 73 | 74 | func (t *TestDriver) FrameworkReregistered(ctx context.Context, from *upid.UPID, msg proto.Message) { 75 | t.eventLock.Lock() 76 | defer t.eventLock.Unlock() 77 | t.frameworkReregistered(ctx, from, msg) 78 | } 79 | -------------------------------------------------------------------------------- /api/v0/auth/sasl/mech/crammd5/mechanism.go: -------------------------------------------------------------------------------- 1 | package crammd5 2 | 3 | import ( 4 | "crypto/hmac" 5 | "crypto/md5" 6 | "encoding/hex" 7 | "errors" 8 | "io" 9 | 10 | log "github.com/golang/glog" 11 | "github.com/mesos/mesos-go/api/v0/auth/callback" 12 | "github.com/mesos/mesos-go/api/v0/auth/sasl/mech" 13 | ) 14 | 15 | var ( 16 | Name = "CRAM-MD5" // name this mechanism is registered with 17 | 18 | //TODO(jdef) is this a generic SASL error? if so, move it up to mech 19 | challengeDataRequired = errors.New("challenge data may not be empty") 20 | ) 21 | 22 | func init() { 23 | mech.Register(Name, newInstance) 24 | } 25 | 26 | type mechanism struct { 27 | handler callback.Handler 28 | } 29 | 30 | func (m *mechanism) Handler() callback.Handler { 31 | return m.handler 32 | } 33 | 34 | func (m *mechanism) Discard() { 35 | // noop 36 | } 37 | 38 | func newInstance(h callback.Handler) (mech.Interface, mech.StepFunc, error) { 39 | m := &mechanism{ 40 | handler: h, 41 | } 42 | fn := func(m mech.Interface, data []byte) (mech.StepFunc, []byte, error) { 43 | // noop: no initialization needed 44 | return challengeResponse, nil, nil 45 | } 46 | return m, fn, nil 47 | } 48 | 49 | // algorithm lifted from wikipedia: http://en.wikipedia.org/wiki/CRAM-MD5 50 | // except that the SASL mechanism used by Mesos doesn't leverage base64 encoding 51 | func challengeResponse(m mech.Interface, data []byte) (mech.StepFunc, []byte, error) { 52 | if len(data) == 0 { 53 | return mech.IllegalState, nil, challengeDataRequired 54 | } 55 | decoded := string(data) 56 | log.V(4).Infof("challenge(decoded): %s", decoded) // for deep debugging only 57 | 58 | username := callback.NewName() 59 | secret := callback.NewPassword() 60 | 61 | if err := m.Handler().Handle(username, secret); err != nil { 62 | return mech.IllegalState, nil, err 63 | } 64 | hash := hmac.New(md5.New, secret.Get()) 65 | if _, err := io.WriteString(hash, decoded); err != nil { 66 | return mech.IllegalState, nil, err 67 | } 68 | 69 | codes := hex.EncodeToString(hash.Sum(nil)) 70 | msg := username.Get() + " " + codes 71 | return nil, []byte(msg), nil 72 | } 73 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/pborman/uuid/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "io" 9 | ) 10 | 11 | // randomBits completely fills slice b with random data. 12 | func randomBits(b []byte) { 13 | if _, err := io.ReadFull(rander, b); err != nil { 14 | panic(err.Error()) // rand should never fail 15 | } 16 | } 17 | 18 | // xvalues returns the value of a byte as a hexadecimal digit or 255. 19 | var xvalues = []byte{ 20 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 21 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 22 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 23 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, 24 | 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 25 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 26 | 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 27 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 28 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 29 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 30 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 31 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 32 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 33 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 34 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 35 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 36 | } 37 | 38 | // xtob converts the the first two hex bytes of x into a byte. 39 | func xtob(x string) (byte, bool) { 40 | b1 := xvalues[x[0]] 41 | b2 := xvalues[x[1]] 42 | return (b1 << 4) | b2, b1 != 255 && b2 != 255 43 | } 44 | -------------------------------------------------------------------------------- /api/v1/lib/resources/reduce.go: -------------------------------------------------------------------------------- 1 | package resources 2 | 3 | import ( 4 | "github.com/mesos/mesos-go/api/v1/lib" 5 | "github.com/mesos/mesos-go/api/v1/lib/resourcefilters" 6 | ) 7 | 8 | // Reducer applies some operation to possibly combine an accumulator (acc) and a resource (x), returning 9 | // either the combined result or nil. 10 | type Reducer func(acc, x *mesos.Resource) *mesos.Resource 11 | 12 | // If applies a filter func to a resource reducer; rejected resources are not processed by the receiving reducer. 13 | func (rf Reducer) If(f func(*mesos.Resource) bool) Reducer { 14 | if f == nil { 15 | return rf 16 | } 17 | return func(acc, x *mesos.Resource) *mesos.Resource { 18 | if f(x) { 19 | return rf(acc, x) 20 | } 21 | return acc 22 | } 23 | } 24 | 25 | // IfNot applies a filter func to a resource reducer; accepted resources are not processed by the receiving reducer. 26 | func (rf Reducer) IfNot(f func(*mesos.Resource) bool) Reducer { 27 | if f == nil { 28 | return rf 29 | } 30 | return rf.If(func(r *mesos.Resource) bool { 31 | return !f(r) 32 | }) 33 | } 34 | 35 | // Reduce applies the given Reducer to produce a final Resource, iterating left-to-right over the given 36 | // resources; panics if the Reducer is nil. 37 | func Reduce(rf Reducer, rs ...mesos.Resource) (r *mesos.Resource) { 38 | if rf == nil { 39 | panic("Reduce: reducer func may not be nil") 40 | } 41 | for i := range rs { 42 | r = rf(r, &rs[i]) 43 | } 44 | return 45 | } 46 | 47 | func Sum(fs ...resourcefilters.Filter) Reducer { 48 | return Reducer(func(acc, x *mesos.Resource) *mesos.Resource { 49 | p := acc 50 | if p == nil { 51 | p = x 52 | } 53 | if p == nil { 54 | return nil 55 | } 56 | switch p.GetType() { 57 | case mesos.SCALAR: 58 | return &mesos.Resource{Scalar: acc.GetScalar().Add(x.GetScalar())} 59 | case mesos.RANGES: 60 | return &mesos.Resource{Ranges: acc.GetRanges().Add(x.GetRanges())} 61 | case mesos.SET: 62 | return &mesos.Resource{Set: acc.GetSet().Add(x.GetSet())} 63 | default: 64 | // we can't take the sum of TEXT type 65 | } 66 | return nil 67 | }).If(resourcefilters.Filters(fs).Accepts) 68 | } 69 | -------------------------------------------------------------------------------- /api/v0/mesosproto/authentication.proto: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package mesosproto; 20 | 21 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 22 | 23 | option (gogoproto.gostring_all) = true; 24 | option (gogoproto.equal_all) = true; 25 | option (gogoproto.verbose_equal_all) = true; 26 | option (gogoproto.goproto_stringer_all) = false; 27 | option (gogoproto.stringer_all) = true; 28 | option (gogoproto.populate_all) = true; 29 | option (gogoproto.testgen_all) = true; 30 | option (gogoproto.benchgen_all) = true; 31 | option (gogoproto.marshaler_all) = true; 32 | option (gogoproto.sizer_all) = true; 33 | option (gogoproto.unmarshaler_all) = true; 34 | 35 | message AuthenticateMessage { 36 | required string pid = 1; // PID that needs to be authenticated. 37 | } 38 | 39 | 40 | message AuthenticationMechanismsMessage { 41 | repeated string mechanisms = 1; // List of available SASL mechanisms. 42 | } 43 | 44 | 45 | message AuthenticationStartMessage { 46 | required string mechanism = 1; 47 | optional bytes data = 2; 48 | } 49 | 50 | 51 | message AuthenticationStepMessage { 52 | required bytes data = 1; 53 | } 54 | 55 | 56 | message AuthenticationCompletedMessage {} 57 | 58 | 59 | message AuthenticationFailedMessage {} 60 | 61 | 62 | message AuthenticationErrorMessage { 63 | optional string error = 1; 64 | } 65 | -------------------------------------------------------------------------------- /api/v1/lib/extras/scheduler/offers/filters.go: -------------------------------------------------------------------------------- 1 | package offers 2 | 3 | import ( 4 | "github.com/mesos/mesos-go/api/v1/lib" 5 | "github.com/mesos/mesos-go/api/v1/lib/resources" 6 | ) 7 | 8 | type ( 9 | // Filter accepts or rejects a mesos Offer 10 | Filter interface { 11 | Accept(*mesos.Offer) bool 12 | } 13 | 14 | // FilterFunc returns true if the given Offer passes the filter 15 | FilterFunc func(*mesos.Offer) bool 16 | ) 17 | 18 | // Accept implements Filter for FilterFunc 19 | func (f FilterFunc) Accept(o *mesos.Offer) bool { 20 | if f == nil { 21 | return true 22 | } 23 | return f(o) 24 | } 25 | 26 | func not(f Filter) Filter { 27 | return FilterFunc(func(offer *mesos.Offer) bool { return !f.Accept(offer) }) 28 | } 29 | 30 | // ByHostname returns a Filter that accepts offers with a matching Hostname 31 | func ByHostname(hostname string) Filter { 32 | if hostname == "" { 33 | return FilterFunc(nil) 34 | } 35 | return FilterFunc(func(o *mesos.Offer) bool { 36 | return o.Hostname == hostname 37 | }) 38 | } 39 | 40 | // ByAttributes returns a Filter that accepts offers with an attribute set accepted by 41 | // the provided Attribute filter func. 42 | func ByAttributes(f func(attr []mesos.Attribute) bool) Filter { 43 | if f == nil { 44 | return FilterFunc(nil) 45 | } 46 | return FilterFunc(func(o *mesos.Offer) bool { 47 | return f(o.Attributes) 48 | }) 49 | } 50 | 51 | func ByExecutors(f func(exec []mesos.ExecutorID) bool) Filter { 52 | if f == nil { 53 | return FilterFunc(nil) 54 | } 55 | return FilterFunc(func(o *mesos.Offer) bool { 56 | return f(o.ExecutorIDs) 57 | }) 58 | } 59 | 60 | func ByUnavailability(f func(u *mesos.Unavailability) bool) Filter { 61 | if f == nil { 62 | return FilterFunc(nil) 63 | } 64 | return FilterFunc(func(o *mesos.Offer) bool { 65 | return f(o.Unavailability) 66 | }) 67 | } 68 | 69 | // ContainsResources returns a filter that returns true if the Resources of an Offer 70 | // contain the wanted Resources. 71 | func ContainsResources(wanted mesos.Resources) Filter { 72 | return FilterFunc(func(o *mesos.Offer) bool { 73 | return resources.ContainsAll(resources.Flatten(mesos.Resources(o.Resources)), wanted) 74 | }) 75 | } 76 | -------------------------------------------------------------------------------- /api/v0/examples/Godeps/_workspace/src/github.com/gogo/protobuf/proto/text_gogo.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved. 2 | // http://github.com/gogo/protobuf/gogoproto 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | package proto 28 | 29 | import ( 30 | "fmt" 31 | "reflect" 32 | ) 33 | 34 | func writeEnum(w *textWriter, v reflect.Value, props *Properties) error { 35 | m, ok := enumStringMaps[props.Enum] 36 | if !ok { 37 | if err := writeAny(w, v, props); err != nil { 38 | return err 39 | } 40 | } 41 | key := int32(0) 42 | if v.Kind() == reflect.Ptr { 43 | key = int32(v.Elem().Int()) 44 | } else { 45 | key = int32(v.Int()) 46 | } 47 | s, ok := m[key] 48 | if !ok { 49 | if err := writeAny(w, v, props); err != nil { 50 | return err 51 | } 52 | } 53 | _, err := fmt.Fprint(w, s) 54 | return err 55 | } 56 | -------------------------------------------------------------------------------- /api/v0/detector/zoo/mock/conn.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | package mock 20 | 21 | import ( 22 | "github.com/samuel/go-zookeeper/zk" 23 | "github.com/stretchr/testify/mock" 24 | ) 25 | 26 | // Impersontates a zk.Connection 27 | // It implements interface Connector 28 | type Connector struct { 29 | mock.Mock 30 | } 31 | 32 | func NewConnector() *Connector { 33 | return new(Connector) 34 | } 35 | 36 | func (conn *Connector) Close() { 37 | conn.Called() 38 | } 39 | 40 | func (conn *Connector) ChildrenW(path string) ([]string, *zk.Stat, <-chan zk.Event, error) { 41 | args := conn.Called(path) 42 | var ( 43 | arg0 []string 44 | arg1 *zk.Stat 45 | arg2 <-chan zk.Event 46 | ) 47 | if args.Get(0) != nil { 48 | arg0 = args.Get(0).([]string) 49 | } 50 | if args.Get(1) != nil { 51 | arg1 = args.Get(1).(*zk.Stat) 52 | } 53 | if args.Get(2) != nil { 54 | arg2 = args.Get(2).(<-chan zk.Event) 55 | } 56 | return arg0, arg1, arg2, args.Error(3) 57 | } 58 | 59 | func (conn *Connector) Children(path string) ([]string, *zk.Stat, error) { 60 | args := conn.Called(path) 61 | return args.Get(0).([]string), 62 | args.Get(1).(*zk.Stat), 63 | args.Error(2) 64 | } 65 | 66 | func (conn *Connector) Get(path string) ([]byte, *zk.Stat, error) { 67 | args := conn.Called(path) 68 | return args.Get(0).([]byte), 69 | args.Get(1).(*zk.Stat), 70 | args.Error(2) 71 | } 72 | -------------------------------------------------------------------------------- /api/v1/lib/encoding/framing/framing.go: -------------------------------------------------------------------------------- 1 | package framing 2 | 3 | import ( 4 | "io" 5 | "io/ioutil" 6 | ) 7 | 8 | type Error string 9 | 10 | func (err Error) Error() string { return string(err) } 11 | 12 | const ( 13 | ErrorUnderrun = Error("frame underrun, unexpected EOF") 14 | ErrorBadSize = Error("bad frame size") 15 | ErrorOversizedFrame = Error("oversized frame, max size exceeded") 16 | ) 17 | 18 | type ( 19 | // Reader generates data frames from some source, returning io.EOF when the end of the input stream is 20 | // detected. 21 | Reader interface { 22 | ReadFrame() (frame []byte, err error) 23 | } 24 | 25 | // ReaderFunc is the functional adaptation of Reader. 26 | ReaderFunc func() ([]byte, error) 27 | 28 | // Writer sends whole frames to some endpoint; returns io.ErrShortWrite if the frame is only partially written. 29 | Writer interface { 30 | WriteFrame(frame []byte) error 31 | } 32 | 33 | // WriterFunc is the functional adaptation of Writer. 34 | WriterFunc func([]byte) error 35 | ) 36 | 37 | func (f ReaderFunc) ReadFrame() ([]byte, error) { return f() } 38 | func (f WriterFunc) WriteFrame(b []byte) error { return f(b) } 39 | 40 | var _ = Reader(ReaderFunc(nil)) 41 | var _ = Writer(WriterFunc(nil)) 42 | 43 | // EOFReaderFunc always returns nil, io.EOF; it implements the ReaderFunc API. 44 | func EOFReaderFunc() ([]byte, error) { return nil, io.EOF } 45 | 46 | var _ = ReaderFunc(EOFReaderFunc) // sanity check 47 | 48 | // ReadAll returns a reader func that returns the complete contents of `r` in a single frame. 49 | // A zero length frame is treated as an "end of stream" condition, returning io.EOF. 50 | func ReadAll(r io.Reader) ReaderFunc { 51 | return func() (b []byte, err error) { 52 | b, err = ioutil.ReadAll(r) 53 | if len(b) == 0 && err == nil { 54 | err = io.EOF 55 | } 56 | return 57 | } 58 | } 59 | 60 | // WriterFor adapts an io.Writer to the Writer interface. All buffers are written to `w` without decoration or 61 | // modification. 62 | func WriterFor(w io.Writer) WriterFunc { 63 | return func(b []byte) error { 64 | n, err := w.Write(b) 65 | if err == nil && n != len(b) { 66 | return io.ErrShortWrite 67 | } 68 | return err 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /api/v1/lib/labels.go: -------------------------------------------------------------------------------- 1 | package mesos 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | ) 7 | 8 | type labelList []Label // convenience type, for working with unwrapped Label slices 9 | 10 | // Equivalent returns true if left and right have the same labels. Order is not important. 11 | func (left *Labels) Equivalent(right *Labels) bool { 12 | return labelList(left.GetLabels()).Equivalent(labelList(right.GetLabels())) 13 | } 14 | 15 | // Equivalent returns true if left and right have the same labels. Order is not important. 16 | func (left labelList) Equivalent(right labelList) bool { 17 | if len(left) != len(right) { 18 | return false 19 | } else { 20 | for i := range left { 21 | found := false 22 | for j := range right { 23 | if left[i].Equivalent(right[j]) { 24 | found = true 25 | break 26 | } 27 | } 28 | if !found { 29 | return false 30 | } 31 | } 32 | return true 33 | } 34 | } 35 | 36 | // Equivalent returns true if left and right represent the same Label. 37 | func (left Label) Equivalent(right Label) bool { 38 | if left.Key != right.Key { 39 | return false 40 | } 41 | if left.Value == nil { 42 | return right.Value == nil 43 | } else { 44 | return right.Value != nil && *left.Value == *right.Value 45 | } 46 | } 47 | 48 | func (left Label) writeTo(w io.Writer) (n int64, err error) { 49 | write := func(s string) { 50 | if err != nil { 51 | return 52 | } 53 | var n2 int 54 | n2, err = io.WriteString(w, s) 55 | n += int64(n2) 56 | } 57 | write(left.Key) 58 | if s := left.GetValue(); s != "" { 59 | write("=") 60 | write(s) 61 | } 62 | return 63 | } 64 | 65 | func (left *Labels) writeTo(w io.Writer) (n int64, err error) { 66 | var ( 67 | lab = left.GetLabels() 68 | n2 int 69 | n3 int64 70 | ) 71 | for i := range lab { 72 | if i > 0 { 73 | n2, err = io.WriteString(w, ",") 74 | n += int64(n2) 75 | if err != nil { 76 | break 77 | } 78 | } 79 | n3, err = lab[i].writeTo(w) 80 | n += n3 81 | if err != nil { 82 | break 83 | } 84 | } 85 | return 86 | } 87 | 88 | func (left *Labels) Format() string { 89 | if left == nil { 90 | return "" 91 | } 92 | var b bytes.Buffer 93 | left.writeTo(&b) 94 | return b.String() 95 | } 96 | -------------------------------------------------------------------------------- /api/v1/lib/roles/role.go: -------------------------------------------------------------------------------- 1 | package roles 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | "unicode" 7 | ) 8 | 9 | // Role is a deprecated type. 10 | type Role string 11 | 12 | const defaultRole = Role("*") 13 | 14 | func (r Role) IsDefault() bool { 15 | return r == defaultRole 16 | } 17 | 18 | func (r Role) Assign() func(interface{}) { 19 | return func(v interface{}) { 20 | type roler interface { 21 | WithRole(string) 22 | } 23 | if ri, ok := v.(roler); ok { 24 | ri.WithRole(string(r)) 25 | } 26 | } 27 | } 28 | 29 | func (r Role) Proto() *string { 30 | s := string(r) 31 | return &s 32 | } 33 | 34 | // IsStrictSubroleOf returns true if left is a strict subrole of right. 35 | func IsStrictSubroleOf(left, right string) bool { 36 | return len(left) > len(right) && left[len(right)] == '/' && strings.HasPrefix(left, right) 37 | } 38 | 39 | var illegalComponents = map[string]struct{}{ 40 | ".": struct{}{}, 41 | "..": struct{}{}, 42 | "*": struct{}{}, 43 | } 44 | 45 | func Parse(s string) (string, error) { 46 | if s == string(defaultRole) { 47 | return s, nil 48 | } 49 | if strings.HasPrefix(s, "/") { 50 | return "", fmt.Errorf("role %q cannot start with a slash", s) 51 | } 52 | if strings.HasSuffix(s, "/") { 53 | return "", fmt.Errorf("role %q cannot end with a slash", s) 54 | } 55 | 56 | // validate each component in the role path 57 | for _, part := range strings.Split(s, "/") { 58 | if part == "" { 59 | return "", fmt.Errorf("role %q cannot contain two adjacent slashes", s) 60 | } 61 | if bad, found := illegalComponents[part]; found { 62 | return "", fmt.Errorf("role %q cannot contain %q as a component", s, bad) 63 | } 64 | if strings.HasPrefix(part, "-") { 65 | return "", fmt.Errorf("role component %q is invalid because it begins with a dash", part) 66 | } 67 | if strings.IndexFunc(part, func(r rune) bool { return unicode.IsSpace(r) || unicode.IsControl(r) }) > -1 { 68 | return "", fmt.Errorf("role component %q is invalid because it contains backspace or whitespace", part) 69 | } 70 | } 71 | return s, nil 72 | } 73 | 74 | func Validate(roles ...string) error { 75 | for i := range roles { 76 | _, err := Parse(roles[i]) 77 | if err != nil { 78 | return err 79 | } 80 | } 81 | return nil 82 | } 83 | -------------------------------------------------------------------------------- /api/v1/lib/extras/executor/callrules/metrics_generated_test.go: -------------------------------------------------------------------------------- 1 | package callrules 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib -import github.com/mesos/mesos-go/api/v1/lib/executor -type E:*executor.Call:&executor.Call{} -type ET:executor.Call_Type -type Z:mesos.Response:&mesos.ResponseWrapper{} -output metrics_generated.go 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | "errors" 9 | "reflect" 10 | "testing" 11 | 12 | "github.com/mesos/mesos-go/api/v1/lib" 13 | "github.com/mesos/mesos-go/api/v1/lib/executor" 14 | ) 15 | 16 | func TestMetrics(t *testing.T) { 17 | var ( 18 | i int 19 | ctx = context.Background() 20 | p = &executor.Call{} 21 | a = errors.New("a") 22 | h = func(f func() error, _ ...string) error { 23 | i++ 24 | return f() 25 | } 26 | ) 27 | var zp = &mesos.ResponseWrapper{} 28 | for ti, tc := range []struct { 29 | ctx context.Context 30 | e *executor.Call 31 | z mesos.Response 32 | err error 33 | }{ 34 | {ctx, p, zp, a}, 35 | {ctx, p, zp, nil}, 36 | 37 | {ctx, p, nil, a}, 38 | {ctx, nil, zp, a}, 39 | } { 40 | for ri, r := range []Rule{ 41 | Metrics(h, nil), // default labeler 42 | Metrics(h, func(_ context.Context, _ *executor.Call) []string { return nil }), // custom labeler 43 | } { 44 | c, e, z, err := r.Eval(tc.ctx, tc.e, tc.z, tc.err, ChainIdentity) 45 | if !reflect.DeepEqual(c, tc.ctx) { 46 | t.Errorf("test case %d: expected context %q instead of %q", ti, tc.ctx, c) 47 | } 48 | if !reflect.DeepEqual(e, tc.e) { 49 | t.Errorf("test case %d: expected event %q instead of %q", ti, tc.e, e) 50 | } 51 | if !reflect.DeepEqual(z, tc.z) { 52 | t.Errorf("expected return object %q instead of %q", z, tc.z) 53 | } 54 | if !reflect.DeepEqual(err, tc.err) { 55 | t.Errorf("test case %d: expected error %q instead of %q", ti, tc.err, err) 56 | } 57 | if y := (ti * 2) + ri + 1; y != i { 58 | t.Errorf("test case %d: expected count %q instead of %q", ti, y, i) 59 | } 60 | } 61 | } 62 | func() { 63 | defer func() { 64 | if x := recover(); x != nil { 65 | t.Log("intercepted expected panic", x) 66 | } 67 | }() 68 | _ = Metrics(nil, nil) 69 | t.Fatalf("expected a panic because nil harness is not allowed") 70 | }() 71 | } 72 | -------------------------------------------------------------------------------- /api/v1/lib/extras/scheduler/callrules/metrics_generated_test.go: -------------------------------------------------------------------------------- 1 | package callrules 2 | 3 | // go generate -import github.com/mesos/mesos-go/api/v1/lib -import github.com/mesos/mesos-go/api/v1/lib/scheduler -type E:*scheduler.Call:&scheduler.Call{} -type ET:scheduler.Call_Type -type Z:mesos.Response:&mesos.ResponseWrapper{} -output metrics_generated.go 4 | // GENERATED CODE FOLLOWS; DO NOT EDIT. 5 | 6 | import ( 7 | "context" 8 | "errors" 9 | "reflect" 10 | "testing" 11 | 12 | "github.com/mesos/mesos-go/api/v1/lib" 13 | "github.com/mesos/mesos-go/api/v1/lib/scheduler" 14 | ) 15 | 16 | func TestMetrics(t *testing.T) { 17 | var ( 18 | i int 19 | ctx = context.Background() 20 | p = &scheduler.Call{} 21 | a = errors.New("a") 22 | h = func(f func() error, _ ...string) error { 23 | i++ 24 | return f() 25 | } 26 | ) 27 | var zp = &mesos.ResponseWrapper{} 28 | for ti, tc := range []struct { 29 | ctx context.Context 30 | e *scheduler.Call 31 | z mesos.Response 32 | err error 33 | }{ 34 | {ctx, p, zp, a}, 35 | {ctx, p, zp, nil}, 36 | 37 | {ctx, p, nil, a}, 38 | {ctx, nil, zp, a}, 39 | } { 40 | for ri, r := range []Rule{ 41 | Metrics(h, nil), // default labeler 42 | Metrics(h, func(_ context.Context, _ *scheduler.Call) []string { return nil }), // custom labeler 43 | } { 44 | c, e, z, err := r.Eval(tc.ctx, tc.e, tc.z, tc.err, ChainIdentity) 45 | if !reflect.DeepEqual(c, tc.ctx) { 46 | t.Errorf("test case %d: expected context %q instead of %q", ti, tc.ctx, c) 47 | } 48 | if !reflect.DeepEqual(e, tc.e) { 49 | t.Errorf("test case %d: expected event %q instead of %q", ti, tc.e, e) 50 | } 51 | if !reflect.DeepEqual(z, tc.z) { 52 | t.Errorf("expected return object %q instead of %q", z, tc.z) 53 | } 54 | if !reflect.DeepEqual(err, tc.err) { 55 | t.Errorf("test case %d: expected error %q instead of %q", ti, tc.err, err) 56 | } 57 | if y := (ti * 2) + ri + 1; y != i { 58 | t.Errorf("test case %d: expected count %q instead of %q", ti, y, i) 59 | } 60 | } 61 | } 62 | func() { 63 | defer func() { 64 | if x := recover(); x != nil { 65 | t.Log("intercepted expected panic", x) 66 | } 67 | }() 68 | _ = Metrics(nil, nil) 69 | t.Fatalf("expected a panic because nil harness is not allowed") 70 | }() 71 | } 72 | -------------------------------------------------------------------------------- /api/v1/lib/httpcli/httpmaster/util.go: -------------------------------------------------------------------------------- 1 | package httpmaster 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/mesos/mesos-go/api/v1/lib/client" 7 | "github.com/mesos/mesos-go/api/v1/lib/httpcli" 8 | "github.com/mesos/mesos-go/api/v1/lib/master" 9 | ) 10 | 11 | func classifyResponse(c *master.Call) (rc client.ResponseClass, err error) { 12 | if c == nil { 13 | err = httpcli.ProtocolError("nil master.Call not allowed") 14 | return 15 | } 16 | 17 | switch t := c.GetType(); t { 18 | // singleton 19 | case master.Call_GET_HEALTH, 20 | master.Call_GET_FLAGS, 21 | master.Call_GET_VERSION, 22 | master.Call_GET_METRICS, 23 | master.Call_GET_LOGGING_LEVEL, 24 | master.Call_LIST_FILES, 25 | master.Call_READ_FILE, 26 | master.Call_GET_STATE, 27 | master.Call_GET_AGENTS, 28 | master.Call_GET_FRAMEWORKS, 29 | master.Call_GET_EXECUTORS, 30 | master.Call_GET_OPERATIONS, 31 | master.Call_GET_TASKS, 32 | master.Call_GET_ROLES, 33 | master.Call_GET_WEIGHTS, 34 | master.Call_GET_MASTER, 35 | master.Call_GET_MAINTENANCE_STATUS, 36 | master.Call_GET_MAINTENANCE_SCHEDULE, 37 | master.Call_GET_QUOTA: 38 | rc = client.ResponseClassSingleton 39 | 40 | // streaming 41 | case master.Call_SUBSCRIBE: 42 | // for some reason, the docs say that thr format is recordio (streaming) but HTTP negotiation 43 | // uses application/json or application/x-protobuf; use "auto" class, similar to sched/exec API 44 | rc = client.ResponseClassAuto 45 | 46 | // no-data 47 | case master.Call_SET_LOGGING_LEVEL, 48 | master.Call_UPDATE_WEIGHTS, 49 | master.Call_RESERVE_RESOURCES, 50 | master.Call_UNRESERVE_RESOURCES, 51 | master.Call_CREATE_VOLUMES, 52 | master.Call_DESTROY_VOLUMES, 53 | master.Call_GROW_VOLUME, 54 | master.Call_SHRINK_VOLUME, 55 | master.Call_UPDATE_MAINTENANCE_SCHEDULE, 56 | master.Call_START_MAINTENANCE, 57 | master.Call_STOP_MAINTENANCE, 58 | master.Call_SET_QUOTA, 59 | master.Call_REMOVE_QUOTA, 60 | master.Call_UPDATE_QUOTA, 61 | master.Call_MARK_AGENT_GONE, 62 | master.Call_TEARDOWN, 63 | master.Call_DRAIN_AGENT, 64 | master.Call_DEACTIVATE_AGENT, 65 | master.Call_REACTIVATE_AGENT: 66 | rc = client.ResponseClassNoData 67 | 68 | default: 69 | err = httpcli.ProtocolError(fmt.Sprintf("unsupported master.Call type: %v", t)) 70 | } 71 | return 72 | } 73 | --------------------------------------------------------------------------------