├── Godeps ├── _workspace │ ├── .gitignore │ └── src │ │ ├── github.com │ │ ├── Sirupsen │ │ │ └── logrus │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── terminal_openbsd.go │ │ │ │ ├── terminal_linux.go │ │ │ │ ├── terminal_darwin.go │ │ │ │ ├── terminal_freebsd.go │ │ │ │ ├── CHANGELOG.md │ │ │ │ ├── hooks │ │ │ │ ├── syslog │ │ │ │ │ ├── README.md │ │ │ │ │ ├── syslog_test.go │ │ │ │ │ └── syslog.go │ │ │ │ ├── papertrail │ │ │ │ │ ├── papertrail_test.go │ │ │ │ │ ├── papertrail.go │ │ │ │ │ └── README.md │ │ │ │ ├── airbrake │ │ │ │ │ └── airbrake.go │ │ │ │ ├── bugsnag │ │ │ │ │ ├── bugsnag_test.go │ │ │ │ │ └── bugsnag.go │ │ │ │ └── sentry │ │ │ │ │ ├── README.md │ │ │ │ │ ├── sentry_test.go │ │ │ │ │ └── sentry.go │ │ │ │ ├── terminal_notwindows.go │ │ │ │ ├── writer.go │ │ │ │ ├── terminal_windows.go │ │ │ │ ├── examples │ │ │ │ ├── hook │ │ │ │ │ └── hook.go │ │ │ │ └── basic │ │ │ │ │ └── basic.go │ │ │ │ ├── json_formatter.go │ │ │ │ ├── LICENSE │ │ │ │ ├── hooks.go │ │ │ │ ├── entry_test.go │ │ │ │ ├── formatters │ │ │ │ └── logstash │ │ │ │ │ ├── logstash_test.go │ │ │ │ │ └── logstash.go │ │ │ │ ├── formatter.go │ │ │ │ ├── text_formatter_test.go │ │ │ │ ├── formatter_bench_test.go │ │ │ │ ├── hook_test.go │ │ │ │ ├── logrus.go │ │ │ │ └── json_formatter_test.go │ │ ├── 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 │ │ │ │ ├── mutations.go │ │ │ │ ├── doc.go │ │ │ │ ├── fixture_test.go │ │ │ │ ├── conversions.go │ │ │ │ └── map_test.go │ │ │ └── testify │ │ │ │ ├── assert │ │ │ │ └── errors.go │ │ │ │ └── mock │ │ │ │ └── doc.go │ │ ├── mesos │ │ │ └── mesos-go │ │ │ │ ├── upid │ │ │ │ ├── doc.go │ │ │ │ ├── upid_test.go │ │ │ │ └── upid.go │ │ │ │ ├── mesosproto │ │ │ │ ├── Makefile │ │ │ │ ├── internal.proto │ │ │ │ ├── registry.proto │ │ │ │ ├── state.proto │ │ │ │ ├── internal.pb.go │ │ │ │ ├── registry.pb.go │ │ │ │ └── containerizer.proto │ │ │ │ ├── mesosutil │ │ │ │ ├── constants.go │ │ │ │ ├── process │ │ │ │ │ └── process.go │ │ │ │ └── node.go │ │ │ │ ├── detector │ │ │ │ ├── zoo │ │ │ │ │ ├── doc.go │ │ │ │ │ ├── plugin.go │ │ │ │ │ ├── plugin_test.go │ │ │ │ │ ├── types.go │ │ │ │ │ ├── mocked_conn.go │ │ │ │ │ └── mocked_detect.go │ │ │ │ ├── doc.go │ │ │ │ ├── factory_test.go │ │ │ │ └── interface.go │ │ │ │ ├── messenger │ │ │ │ ├── testmessage │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── testmessage.proto │ │ │ │ │ └── generator.go │ │ │ │ ├── doc.go │ │ │ │ ├── message.go │ │ │ │ ├── README.md │ │ │ │ ├── transporter.go │ │ │ │ └── mocked_messenger.go │ │ │ │ ├── scheduler │ │ │ │ ├── plugins.go │ │ │ │ ├── doc.go │ │ │ │ ├── handler.go │ │ │ │ ├── mock_scheduler.go │ │ │ │ └── schedcache.go │ │ │ │ └── auth │ │ │ │ ├── callback │ │ │ │ ├── name.go │ │ │ │ ├── password.go │ │ │ │ ├── interprocess.go │ │ │ │ └── interface.go │ │ │ │ ├── sasl │ │ │ │ ├── mech │ │ │ │ │ ├── plugins.go │ │ │ │ │ ├── interface.go │ │ │ │ │ └── crammd5 │ │ │ │ │ │ └── mechanism.go │ │ │ │ ├── context.go │ │ │ │ └── authenticatee_test.go │ │ │ │ ├── interface.go │ │ │ │ └── login.go │ │ ├── samuel │ │ │ └── go-zookeeper │ │ │ │ └── zk │ │ │ │ ├── util_test.go │ │ │ │ ├── constants_test.go │ │ │ │ ├── util.go │ │ │ │ ├── structs_test.go │ │ │ │ ├── lock_test.go │ │ │ │ ├── lock.go │ │ │ │ ├── server_help.go │ │ │ │ └── tracer.go │ │ ├── golang │ │ │ └── glog │ │ │ │ ├── README │ │ │ │ └── glog_file.go │ │ └── gogo │ │ │ └── protobuf │ │ │ └── proto │ │ │ ├── lib_gogo.go │ │ │ ├── Makefile │ │ │ ├── testdata │ │ │ ├── Makefile │ │ │ └── golden_test.go │ │ │ ├── text_gogo.go │ │ │ ├── size2_test.go │ │ │ ├── message_set_test.go │ │ │ ├── skip_gogo.go │ │ │ └── extensions_test.go │ │ ├── code.google.com │ │ └── p │ │ │ └── go-uuid │ │ │ └── uuid │ │ │ ├── doc.go │ │ │ ├── version4.go │ │ │ ├── version1.go │ │ │ ├── LICENSE │ │ │ ├── hash.go │ │ │ ├── util.go │ │ │ ├── dce.go │ │ │ └── node.go │ │ └── golang.org │ │ └── x │ │ └── net │ │ └── context │ │ └── withtimeout_test.go ├── Readme └── Godeps.json ├── .gitignore └── README.md /Godeps/_workspace/.gitignore: -------------------------------------------------------------------------------- 1 | /pkg 2 | /bin 3 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/.gitignore: -------------------------------------------------------------------------------- 1 | logrus 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/stretchr/objx/value_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/upid/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package upid defines the UPID type and some utilities of the UPID. 3 | */ 4 | package upid 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.2 4 | - 1.3 5 | - 1.4 6 | - tip 7 | install: 8 | - go get -t ./... 9 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/mesosproto/Makefile: -------------------------------------------------------------------------------- 1 | all: *.proto 2 | protoc --proto_path=${GOPATH}/src:${GOPATH}/src/github.com/gogo/protobuf/protobuf:. --gogo_out=. *.proto 3 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/terminal_openbsd.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import "syscall" 4 | 5 | const ioctlReadTermios = syscall.TIOCGETA 6 | 7 | type Termios syscall.Termios 8 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/mesosutil/constants.go: -------------------------------------------------------------------------------- 1 | package mesosutil 2 | 3 | const ( 4 | // MesosVersion indicates the supported mesos version. 5 | MesosVersion = "0.20.0" 6 | ) 7 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/detector/zoo/doc.go: -------------------------------------------------------------------------------- 1 | // Zookeeper-based mesos-master leaderhip detection. 2 | // Implements support for optional detector.AllMasters interface. 3 | package zoo 4 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/scheduler/plugins.go: -------------------------------------------------------------------------------- 1 | package scheduler 2 | 3 | import ( 4 | _ "github.com/mesos/mesos-go/auth/sasl" 5 | _ "github.com/mesos/mesos-go/auth/sasl/mech/crammd5" 6 | _ "github.com/mesos/mesos-go/detector/zoo" 7 | ) 8 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/detector/zoo/plugin.go: -------------------------------------------------------------------------------- 1 | package zoo 2 | 3 | import ( 4 | "github.com/mesos/mesos-go/detector" 5 | ) 6 | 7 | func init() { 8 | detector.Register("zk://", detector.PluginFactory(func(spec string) (detector.Master, error) { 9 | return NewMasterDetector(spec) 10 | })) 11 | } 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/terminal_linux.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package logrus 7 | 8 | import "syscall" 9 | 10 | const ioctlReadTermios = syscall.TCGETS 11 | 12 | type Termios syscall.Termios 13 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/terminal_darwin.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package logrus 7 | 8 | import "syscall" 9 | 10 | const ioctlReadTermios = syscall.TIOCGETA 11 | 12 | type Termios syscall.Termios 13 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.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 | *.test 24 | *.prof 25 | 26 | # Vim 27 | *.swp 28 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/util_test.go: -------------------------------------------------------------------------------- 1 | package zk 2 | 3 | import "testing" 4 | 5 | func TestFormatServers(t *testing.T) { 6 | servers := []string{"127.0.0.1:2181", "127.0.0.42", "127.0.42.1:8811"} 7 | r := []string{"127.0.0.1:2181", "127.0.0.42:2181", "127.0.42.1:8811"} 8 | 9 | var s []string 10 | s = FormatServers(servers) 11 | 12 | for i := range s { 13 | if s[i] != r[i] { 14 | t.Errorf("%v should equal %v", s[i], r[i]) 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/terminal_freebsd.go: -------------------------------------------------------------------------------- 1 | /* 2 | Go 1.2 doesn't include Termios for FreeBSD. This should be added in 1.3 and this could be merged with terminal_darwin. 3 | */ 4 | package logrus 5 | 6 | import ( 7 | "syscall" 8 | ) 9 | 10 | const ioctlReadTermios = syscall.TIOCGETA 11 | 12 | type Termios struct { 13 | Iflag uint32 14 | Oflag uint32 15 | Cflag uint32 16 | Lflag uint32 17 | Cc [20]uint8 18 | Ispeed uint32 19 | Ospeed uint32 20 | } 21 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.8.2 2 | 3 | logrus: fix more Fatal family functions 4 | 5 | # 0.8.1 6 | 7 | logrus: fix not exiting on `Fatalf` and `Fatalln` 8 | 9 | # 0.8.0 10 | 11 | logrus: defaults to stderr instead of stdout 12 | hooks/sentry: add special field for `*http.Request` 13 | formatter/text: ignore Windows for colors 14 | 15 | # 0.7.3 16 | 17 | formatter/\*: allow configuration of timestamp layout 18 | 19 | # 0.7.2 20 | 21 | formatter/text: Add configuration option for time format (#158) 22 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/detector/zoo/plugin_test.go: -------------------------------------------------------------------------------- 1 | package zoo 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hooks/syslog/README.md: -------------------------------------------------------------------------------- 1 | # Syslog Hooks for Logrus :walrus: 2 | 3 | ## Usage 4 | 5 | ```go 6 | import ( 7 | "log/syslog" 8 | "github.com/Sirupsen/logrus" 9 | logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog" 10 | ) 11 | 12 | func main() { 13 | log := logrus.New() 14 | hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "") 15 | 16 | if err == nil { 17 | log.Hooks.Add(hook) 18 | } 19 | } 20 | ``` 21 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/auth/callback/interprocess.go: -------------------------------------------------------------------------------- 1 | package callback 2 | 3 | import ( 4 | "github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hooks/papertrail/papertrail_test.go: -------------------------------------------------------------------------------- 1 | package logrus_papertrail 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/Sirupsen/logrus" 8 | "github.com/stvp/go-udp-testing" 9 | ) 10 | 11 | func TestWritingToUDP(t *testing.T) { 12 | port := 16661 13 | udp.SetAddr(fmt.Sprintf(":%d", port)) 14 | 15 | hook, err := NewPapertrailHook("localhost", port, "test") 16 | if err != nil { 17 | t.Errorf("Unable to connect to local UDP server.") 18 | } 19 | 20 | log := logrus.New() 21 | log.Hooks.Add(hook) 22 | 23 | udp.ShouldReceive(t, "foo", func() { 24 | log.Info("foo") 25 | }) 26 | } 27 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/constants_test.go: -------------------------------------------------------------------------------- 1 | package zk 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestModeString(t *testing.T) { 9 | if fmt.Sprintf("%v", ModeUnknown) != "unknown" { 10 | t.Errorf("unknown value should be 'unknown'") 11 | } 12 | 13 | if fmt.Sprintf("%v", ModeLeader) != "leader" { 14 | t.Errorf("leader value should be 'leader'") 15 | } 16 | 17 | if fmt.Sprintf("%v", ModeFollower) != "follower" { 18 | t.Errorf("follower value should be 'follower'") 19 | } 20 | 21 | if fmt.Sprintf("%v", ModeStandalone) != "standalone" { 22 | t.Errorf("standlone value should be 'standalone'") 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/terminal_notwindows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build linux darwin freebsd openbsd 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | // IsTerminal returns true if the given file descriptor is a terminal. 16 | func IsTerminal() bool { 17 | fd := syscall.Stdout 18 | var termios Termios 19 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 20 | return err == 0 21 | } 22 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hooks/syslog/syslog_test.go: -------------------------------------------------------------------------------- 1 | package logrus_syslog 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | "log/syslog" 6 | "testing" 7 | ) 8 | 9 | func TestLocalhostAddAndPrint(t *testing.T) { 10 | log := logrus.New() 11 | hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "") 12 | 13 | if err != nil { 14 | t.Errorf("Unable to connect to local syslog.") 15 | } 16 | 17 | log.Hooks.Add(hook) 18 | 19 | for _, level := range hook.Levels() { 20 | if len(log.Hooks[level]) != 1 { 21 | t.Errorf("SyslogHook was not added. The length of log.Hooks[%v]: %v", level, len(log.Hooks[level])) 22 | } 23 | } 24 | 25 | log.Info("Congratulations!") 26 | } 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/mesosutil/node.go: -------------------------------------------------------------------------------- 1 | package mesosutil 2 | 3 | import ( 4 | "os/exec" 5 | "strings" 6 | 7 | log "github.com/golang/glog" 8 | ) 9 | 10 | //TODO(jdef) copied from kubernetes/pkg/util/node.go 11 | func GetHostname(hostnameOverride string) string { 12 | hostname := []byte(hostnameOverride) 13 | if string(hostname) == "" { 14 | // Note: We use exec here instead of os.Hostname() because we 15 | // want the FQDN, and this is the easiest way to get it. 16 | fqdn, err := exec.Command("hostname", "-f").Output() 17 | if err != nil { 18 | log.Fatalf("Couldn't determine hostname: %v", err) 19 | } 20 | hostname = fqdn 21 | } 22 | return strings.TrimSpace(string(hostname)) 23 | } 24 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/writer.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "runtime" 7 | ) 8 | 9 | func (logger *Logger) Writer() *io.PipeWriter { 10 | reader, writer := io.Pipe() 11 | 12 | go logger.writerScanner(reader) 13 | runtime.SetFinalizer(writer, writerFinalizer) 14 | 15 | return writer 16 | } 17 | 18 | func (logger *Logger) writerScanner(reader *io.PipeReader) { 19 | scanner := bufio.NewScanner(reader) 20 | for scanner.Scan() { 21 | logger.Print(scanner.Text()) 22 | } 23 | if err := scanner.Err(); err != nil { 24 | logger.Errorf("Error while reading from Writer: %s", err) 25 | } 26 | reader.Close() 27 | } 28 | 29 | func writerFinalizer(writer *io.PipeWriter) { 30 | writer.Close() 31 | } 32 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build windows 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | var ( 18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 | ) 20 | 21 | // IsTerminal returns true if the given file descriptor is a terminal. 22 | func IsTerminal() bool { 23 | fd := syscall.Stdout 24 | var st uint32 25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 26 | return r != 0 && e == 0 27 | } 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/examples/hook/hook.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | "github.com/Sirupsen/logrus/hooks/airbrake" 6 | ) 7 | 8 | var log = logrus.New() 9 | 10 | func init() { 11 | log.Formatter = new(logrus.TextFormatter) // default 12 | log.Hooks.Add(airbrake.NewHook("https://example.com", "xyz", "development")) 13 | } 14 | 15 | func main() { 16 | log.WithFields(logrus.Fields{ 17 | "animal": "walrus", 18 | "size": 10, 19 | }).Info("A group of walrus emerges from the ocean") 20 | 21 | log.WithFields(logrus.Fields{ 22 | "omg": true, 23 | "number": 122, 24 | }).Warn("The group's number increased tremendously!") 25 | 26 | log.WithFields(logrus.Fields{ 27 | "omg": true, 28 | "number": 100, 29 | }).Fatal("The ice breaks!") 30 | } 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/scheduler/handler.go: -------------------------------------------------------------------------------- 1 | package scheduler 2 | 3 | import ( 4 | "github.com/mesos/mesos-go/auth/callback" 5 | mesos "github.com/mesos/mesos-go/mesosproto" 6 | "github.com/mesos/mesos-go/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(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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/json_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type JSONFormatter struct { 9 | // TimestampFormat sets the format used for marshaling timestamps. 10 | TimestampFormat string 11 | } 12 | 13 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { 14 | data := make(Fields, len(entry.Data)+3) 15 | for k, v := range entry.Data { 16 | switch v := v.(type) { 17 | case error: 18 | // Otherwise errors are ignored by `encoding/json` 19 | // https://github.com/Sirupsen/logrus/issues/137 20 | data[k] = v.Error() 21 | default: 22 | data[k] = v 23 | } 24 | } 25 | prefixFieldClashes(data) 26 | 27 | timestampFormat := f.TimestampFormat 28 | if timestampFormat == "" { 29 | timestampFormat = DefaultTimestampFormat 30 | } 31 | 32 | data["time"] = entry.Time.Format(timestampFormat) 33 | data["msg"] = entry.Message 34 | data["level"] = entry.Level.String() 35 | 36 | serialized, err := json.Marshal(data) 37 | if err != nil { 38 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 39 | } 40 | return append(serialized, '\n'), nil 41 | } 42 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/auth/sasl/context.go: -------------------------------------------------------------------------------- 1 | package sasl 2 | 3 | import ( 4 | "net" 5 | 6 | "golang.org/x/net/context" 7 | ) 8 | 9 | // unexported to prevent collisions with context keys defined in 10 | // other packages. 11 | type _key int 12 | 13 | // If this package defined other context keys, they would have 14 | // different integer values. 15 | const ( 16 | statusKey _key = iota 17 | bindingAddressKey // bind address for login-related network ops 18 | ) 19 | 20 | func withStatus(ctx context.Context, s statusType) context.Context { 21 | return context.WithValue(ctx, statusKey, s) 22 | } 23 | 24 | func statusFrom(ctx context.Context) statusType { 25 | s, ok := ctx.Value(statusKey).(statusType) 26 | if !ok { 27 | panic("missing status in context") 28 | } 29 | return s 30 | } 31 | 32 | func WithBindingAddress(ctx context.Context, address net.IP) context.Context { 33 | return context.WithValue(ctx, bindingAddressKey, address) 34 | } 35 | 36 | func BindingAddressFrom(ctx context.Context) net.IP { 37 | obj := ctx.Value(bindingAddressKey) 38 | if addr, ok := obj.(net.IP); ok { 39 | return addr 40 | } else { 41 | return nil 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | // interface for handling watcher event when zk.EventNodeChildrenChanged. 18 | type ChildWatcher func(*Client, string) 19 | 20 | // interface for handling errors (session and watch related). 21 | type ErrorHandler func(*Client, error) 22 | 23 | //Factory is an adapter to trap the creation of zk.Conn instances 24 | //since the official zk API does not expose an interface for zk.Conn. 25 | type Factory interface { 26 | create() (Connector, <-chan zk.Event, error) 27 | } 28 | 29 | type asFactory func() (Connector, <-chan zk.Event, error) 30 | 31 | func (f asFactory) create() (Connector, <-chan zk.Event, error) { 32 | return f() 33 | } 34 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simon Eskildsen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/examples/basic/basic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | ) 6 | 7 | var log = logrus.New() 8 | 9 | func init() { 10 | log.Formatter = new(logrus.JSONFormatter) 11 | log.Formatter = new(logrus.TextFormatter) // default 12 | log.Level = logrus.DebugLevel 13 | } 14 | 15 | func main() { 16 | defer func() { 17 | err := recover() 18 | if err != nil { 19 | log.WithFields(logrus.Fields{ 20 | "omg": true, 21 | "err": err, 22 | "number": 100, 23 | }).Fatal("The ice breaks!") 24 | } 25 | }() 26 | 27 | log.WithFields(logrus.Fields{ 28 | "animal": "walrus", 29 | "number": 8, 30 | }).Debug("Started observing beach") 31 | 32 | log.WithFields(logrus.Fields{ 33 | "animal": "walrus", 34 | "size": 10, 35 | }).Info("A group of walrus emerges from the ocean") 36 | 37 | log.WithFields(logrus.Fields{ 38 | "omg": true, 39 | "number": 122, 40 | }).Warn("The group's number increased tremendously!") 41 | 42 | log.WithFields(logrus.Fields{ 43 | "temperature": -4, 44 | }).Debug("Temperature changes") 45 | 46 | log.WithFields(logrus.Fields{ 47 | "animal": "orca", 48 | "size": 9009, 49 | }).Panic("It's over 9000!") 50 | } 51 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hooks.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // A hook to be fired when logging on the logging levels returned from 4 | // `Levels()` on your implementation of the interface. Note that this is not 5 | // fired in a goroutine or a channel with workers, you should handle such 6 | // functionality yourself if your call is non-blocking and you don't wish for 7 | // the logging calls for levels returned from `Levels()` to block. 8 | type Hook interface { 9 | Levels() []Level 10 | Fire(*Entry) error 11 | } 12 | 13 | // Internal type for storing the hooks on a logger instance. 14 | type levelHooks map[Level][]Hook 15 | 16 | // Add a hook to an instance of logger. This is called with 17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. 18 | func (hooks levelHooks) Add(hook Hook) { 19 | for _, level := range hook.Levels() { 20 | hooks[level] = append(hooks[level], hook) 21 | } 22 | } 23 | 24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire 25 | // appropriate hooks for a log entry. 26 | func (hooks levelHooks) Fire(level Level, entry *Entry) error { 27 | for _, hook := range hooks[level] { 28 | if err := hook.Fire(entry); err != nil { 29 | return err 30 | } 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/entry_test.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "testing" 7 | 8 | "github.com/stretchr/testify/assert" 9 | ) 10 | 11 | func TestEntryPanicln(t *testing.T) { 12 | errBoom := fmt.Errorf("boom time") 13 | 14 | defer func() { 15 | p := recover() 16 | assert.NotNil(t, p) 17 | 18 | switch pVal := p.(type) { 19 | case *Entry: 20 | assert.Equal(t, "kaboom", pVal.Message) 21 | assert.Equal(t, errBoom, pVal.Data["err"]) 22 | default: 23 | t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal) 24 | } 25 | }() 26 | 27 | logger := New() 28 | logger.Out = &bytes.Buffer{} 29 | entry := NewEntry(logger) 30 | entry.WithField("err", errBoom).Panicln("kaboom") 31 | } 32 | 33 | func TestEntryPanicf(t *testing.T) { 34 | errBoom := fmt.Errorf("boom again") 35 | 36 | defer func() { 37 | p := recover() 38 | assert.NotNil(t, p) 39 | 40 | switch pVal := p.(type) { 41 | case *Entry: 42 | assert.Equal(t, "kaboom true", pVal.Message) 43 | assert.Equal(t, errBoom, pVal.Data["err"]) 44 | default: 45 | t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal) 46 | } 47 | }() 48 | 49 | logger := New() 50 | logger.Out = &bytes.Buffer{} 51 | entry := NewEntry(logger) 52 | entry.WithField("err", errBoom).Panicf("kaboom %v", true) 53 | } 54 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hooks/airbrake/airbrake.go: -------------------------------------------------------------------------------- 1 | package airbrake 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | 7 | "github.com/Sirupsen/logrus" 8 | "github.com/tobi/airbrake-go" 9 | ) 10 | 11 | // AirbrakeHook to send exceptions to an exception-tracking service compatible 12 | // with the Airbrake API. 13 | type airbrakeHook struct { 14 | APIKey string 15 | Endpoint string 16 | Environment string 17 | } 18 | 19 | func NewHook(endpoint, apiKey, env string) *airbrakeHook { 20 | return &airbrakeHook{ 21 | APIKey: apiKey, 22 | Endpoint: endpoint, 23 | Environment: env, 24 | } 25 | } 26 | 27 | func (hook *airbrakeHook) Fire(entry *logrus.Entry) error { 28 | airbrake.ApiKey = hook.APIKey 29 | airbrake.Endpoint = hook.Endpoint 30 | airbrake.Environment = hook.Environment 31 | 32 | var notifyErr error 33 | err, ok := entry.Data["error"].(error) 34 | if ok { 35 | notifyErr = err 36 | } else { 37 | notifyErr = errors.New(entry.Message) 38 | } 39 | 40 | airErr := airbrake.Notify(notifyErr) 41 | if airErr != nil { 42 | return fmt.Errorf("Failed to send error to Airbrake: %s", airErr) 43 | } 44 | 45 | return nil 46 | } 47 | 48 | func (hook *airbrakeHook) Levels() []logrus.Level { 49 | return []logrus.Level{ 50 | logrus.ErrorLevel, 51 | logrus.FatalLevel, 52 | logrus.PanicLevel, 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/auth/sasl/mech/interface.go: -------------------------------------------------------------------------------- 1 | package mech 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/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, 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:], clock_seq) 38 | copy(uuid[10:], nodeID) 39 | 40 | return uuid 41 | } 42 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/formatters/logstash/logstash_test.go: -------------------------------------------------------------------------------- 1 | package logstash 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "github.com/Sirupsen/logrus" 7 | "github.com/stretchr/testify/assert" 8 | "testing" 9 | ) 10 | 11 | func TestLogstashFormatter(t *testing.T) { 12 | assert := assert.New(t) 13 | 14 | lf := LogstashFormatter{Type: "abc"} 15 | 16 | fields := logrus.Fields{ 17 | "message": "def", 18 | "level": "ijk", 19 | "type": "lmn", 20 | "one": 1, 21 | "pi": 3.14, 22 | "bool": true, 23 | } 24 | 25 | entry := logrus.WithFields(fields) 26 | entry.Message = "msg" 27 | entry.Level = logrus.InfoLevel 28 | 29 | b, _ := lf.Format(entry) 30 | 31 | var data map[string]interface{} 32 | dec := json.NewDecoder(bytes.NewReader(b)) 33 | dec.UseNumber() 34 | dec.Decode(&data) 35 | 36 | // base fields 37 | assert.Equal(json.Number("1"), data["@version"]) 38 | assert.NotEmpty(data["@timestamp"]) 39 | assert.Equal("abc", data["type"]) 40 | assert.Equal("msg", data["message"]) 41 | assert.Equal("info", data["level"]) 42 | 43 | // substituted fields 44 | assert.Equal("def", data["fields.message"]) 45 | assert.Equal("ijk", data["fields.level"]) 46 | assert.Equal("lmn", data["fields.type"]) 47 | 48 | // formats 49 | assert.Equal(json.Number("1"), data["one"]) 50 | assert.Equal(json.Number("3.14"), data["pi"]) 51 | assert.Equal(true, data["bool"]) 52 | } 53 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/mesosproto/registry.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 "mesos.proto"; 22 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 23 | 24 | message Registry { 25 | message Master { 26 | required MasterInfo info = 1; 27 | } 28 | 29 | message Slave { 30 | required SlaveInfo info = 1; 31 | } 32 | 33 | message Slaves { 34 | repeated Slave slaves = 1; 35 | } 36 | 37 | // Most recent leading master. 38 | optional Master master = 1; 39 | 40 | // All admitted slaves. 41 | optional Slaves slaves = 2; 42 | } 43 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/formatters/logstash/logstash.go: -------------------------------------------------------------------------------- 1 | package logstash 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/Sirupsen/logrus" 8 | ) 9 | 10 | // Formatter generates json in logstash format. 11 | // Logstash site: http://logstash.net/ 12 | type LogstashFormatter struct { 13 | Type string // if not empty use for logstash type field. 14 | 15 | // TimestampFormat sets the format used for timestamps. 16 | TimestampFormat string 17 | } 18 | 19 | func (f *LogstashFormatter) Format(entry *logrus.Entry) ([]byte, error) { 20 | entry.Data["@version"] = 1 21 | 22 | if f.TimestampFormat == "" { 23 | f.TimestampFormat = logrus.DefaultTimestampFormat 24 | } 25 | 26 | entry.Data["@timestamp"] = entry.Time.Format(f.TimestampFormat) 27 | 28 | // set message field 29 | v, ok := entry.Data["message"] 30 | if ok { 31 | entry.Data["fields.message"] = v 32 | } 33 | entry.Data["message"] = entry.Message 34 | 35 | // set level field 36 | v, ok = entry.Data["level"] 37 | if ok { 38 | entry.Data["fields.level"] = v 39 | } 40 | entry.Data["level"] = entry.Level.String() 41 | 42 | // set type field 43 | if f.Type != "" { 44 | v, ok = entry.Data["type"] 45 | if ok { 46 | entry.Data["fields.type"] = v 47 | } 48 | entry.Data["type"] = f.Type 49 | } 50 | 51 | serialized, err := json.Marshal(entry.Data) 52 | if err != nil { 53 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 54 | } 55 | return append(serialized, '\n'), nil 56 | } 57 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/scheduler/mock_scheduler.go: -------------------------------------------------------------------------------- 1 | package scheduler 2 | 3 | import ( 4 | log "github.com/golang/glog" 5 | mesos "github.com/mesos/mesos-go/mesosproto" 6 | "github.com/stretchr/testify/mock" 7 | ) 8 | 9 | type MockScheduler struct { 10 | mock.Mock 11 | } 12 | 13 | func NewMockScheduler() *MockScheduler { 14 | return &MockScheduler{} 15 | } 16 | 17 | func (sched *MockScheduler) Registered(SchedulerDriver, *mesos.FrameworkID, *mesos.MasterInfo) { 18 | sched.Called() 19 | } 20 | 21 | func (sched *MockScheduler) Reregistered(SchedulerDriver, *mesos.MasterInfo) { 22 | sched.Called() 23 | } 24 | 25 | func (sched *MockScheduler) Disconnected(SchedulerDriver) { 26 | sched.Called() 27 | } 28 | 29 | func (sched *MockScheduler) ResourceOffers(SchedulerDriver, []*mesos.Offer) { 30 | sched.Called() 31 | } 32 | 33 | func (sched *MockScheduler) OfferRescinded(SchedulerDriver, *mesos.OfferID) { 34 | sched.Called() 35 | } 36 | 37 | func (sched *MockScheduler) StatusUpdate(SchedulerDriver, *mesos.TaskStatus) { 38 | sched.Called() 39 | } 40 | 41 | func (sched *MockScheduler) FrameworkMessage(SchedulerDriver, *mesos.ExecutorID, *mesos.SlaveID, string) { 42 | sched.Called() 43 | } 44 | 45 | func (sched *MockScheduler) SlaveLost(SchedulerDriver, *mesos.SlaveID) { 46 | sched.Called() 47 | } 48 | 49 | func (sched *MockScheduler) ExecutorLost(SchedulerDriver, *mesos.ExecutorID, *mesos.SlaveID, int) { 50 | sched.Called() 51 | } 52 | 53 | func (sched *MockScheduler) Error(d SchedulerDriver, msg string) { 54 | log.Error(msg) 55 | sched.Called() 56 | } 57 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hooks/papertrail/papertrail.go: -------------------------------------------------------------------------------- 1 | package logrus_papertrail 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "os" 7 | "time" 8 | 9 | "github.com/Sirupsen/logrus" 10 | ) 11 | 12 | const ( 13 | format = "Jan 2 15:04:05" 14 | ) 15 | 16 | // PapertrailHook to send logs to a logging service compatible with the Papertrail API. 17 | type PapertrailHook struct { 18 | Host string 19 | Port int 20 | AppName string 21 | UDPConn net.Conn 22 | } 23 | 24 | // NewPapertrailHook creates a hook to be added to an instance of logger. 25 | func NewPapertrailHook(host string, port int, appName string) (*PapertrailHook, error) { 26 | conn, err := net.Dial("udp", fmt.Sprintf("%s:%d", host, port)) 27 | return &PapertrailHook{host, port, appName, conn}, err 28 | } 29 | 30 | // Fire is called when a log event is fired. 31 | func (hook *PapertrailHook) Fire(entry *logrus.Entry) error { 32 | date := time.Now().Format(format) 33 | msg, _ := entry.String() 34 | payload := fmt.Sprintf("<22> %s %s: %s", date, hook.AppName, msg) 35 | 36 | bytesWritten, err := hook.UDPConn.Write([]byte(payload)) 37 | if err != nil { 38 | fmt.Fprintf(os.Stderr, "Unable to send log line to Papertrail via UDP. Wrote %d bytes before error: %v", bytesWritten, err) 39 | return err 40 | } 41 | 42 | return nil 43 | } 44 | 45 | // Levels returns the available logging levels. 46 | func (hook *PapertrailHook) Levels() []logrus.Level { 47 | return []logrus.Level{ 48 | logrus.PanicLevel, 49 | logrus.FatalLevel, 50 | logrus.ErrorLevel, 51 | logrus.WarnLevel, 52 | logrus.InfoLevel, 53 | logrus.DebugLevel, 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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/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 | return fmt.Sprintf("/%s/%s", m.UPID.ID, m.Name) 40 | } 41 | 42 | // NOTE: This should not fail or panic. 43 | func extractNameFromRequestURI(requestURI string) string { 44 | return strings.Split(requestURI, "/")[2] 45 | } 46 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import "time" 4 | 5 | const DefaultTimestampFormat = time.RFC3339 6 | 7 | // The Formatter interface is used to implement a custom Formatter. It takes an 8 | // `Entry`. It exposes all the fields, including the default ones: 9 | // 10 | // * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. 11 | // * `entry.Data["time"]`. The timestamp. 12 | // * `entry.Data["level"]. The level the entry was logged at. 13 | // 14 | // Any additional fields added with `WithField` or `WithFields` are also in 15 | // `entry.Data`. Format is expected to return an array of bytes which are then 16 | // logged to `logger.Out`. 17 | type Formatter interface { 18 | Format(*Entry) ([]byte, error) 19 | } 20 | 21 | // This is to not silently overwrite `time`, `msg` and `level` fields when 22 | // dumping it. If this code wasn't there doing: 23 | // 24 | // logrus.WithField("level", 1).Info("hello") 25 | // 26 | // Would just silently drop the user provided level. Instead with this code 27 | // it'll logged as: 28 | // 29 | // {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."} 30 | // 31 | // It's not exported because it's still using Data in an opinionated way. It's to 32 | // avoid code duplication between the two default formatters. 33 | func prefixFieldClashes(data Fields) { 34 | _, ok := data["time"] 35 | if ok { 36 | data["fields.time"] = data["time"] 37 | } 38 | 39 | _, ok = data["msg"] 40 | if ok { 41 | data["fields.msg"] = data["msg"] 42 | } 43 | 44 | _, ok = data["level"] 45 | if ok { 46 | data["fields.level"] = data["level"] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hooks/bugsnag/bugsnag_test.go: -------------------------------------------------------------------------------- 1 | package logrus_bugsnag 2 | 3 | import ( 4 | "encoding/json" 5 | "errors" 6 | "io/ioutil" 7 | "net/http" 8 | "net/http/httptest" 9 | "testing" 10 | "time" 11 | 12 | "github.com/Sirupsen/logrus" 13 | "github.com/bugsnag/bugsnag-go" 14 | ) 15 | 16 | type notice struct { 17 | Events []struct { 18 | Exceptions []struct { 19 | Message string `json:"message"` 20 | } `json:"exceptions"` 21 | } `json:"events"` 22 | } 23 | 24 | func TestNoticeReceived(t *testing.T) { 25 | msg := make(chan string, 1) 26 | expectedMsg := "foo" 27 | 28 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 29 | var notice notice 30 | data, _ := ioutil.ReadAll(r.Body) 31 | if err := json.Unmarshal(data, ¬ice); err != nil { 32 | t.Error(err) 33 | } 34 | _ = r.Body.Close() 35 | 36 | msg <- notice.Events[0].Exceptions[0].Message 37 | })) 38 | defer ts.Close() 39 | 40 | hook := &bugsnagHook{} 41 | 42 | bugsnag.Configure(bugsnag.Configuration{ 43 | Endpoint: ts.URL, 44 | ReleaseStage: "production", 45 | APIKey: "12345678901234567890123456789012", 46 | Synchronous: true, 47 | }) 48 | 49 | log := logrus.New() 50 | log.Hooks.Add(hook) 51 | 52 | log.WithFields(logrus.Fields{ 53 | "error": errors.New(expectedMsg), 54 | }).Error("Bugsnag will not see this string") 55 | 56 | select { 57 | case received := <-msg: 58 | if received != expectedMsg { 59 | t.Errorf("Unexpected message received: %s", received) 60 | } 61 | case <-time.After(time.Second): 62 | t.Error("Timed out; no notice received by Bugsnag API") 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hooks/papertrail/README.md: -------------------------------------------------------------------------------- 1 | # Papertrail Hook for Logrus :walrus: 2 | 3 | [Papertrail](https://papertrailapp.com) provides hosted log management. Once stored in Papertrail, you can [group](http://help.papertrailapp.com/kb/how-it-works/groups/) your logs on various dimensions, [search](http://help.papertrailapp.com/kb/how-it-works/search-syntax) them, and trigger [alerts](http://help.papertrailapp.com/kb/how-it-works/alerts). 4 | 5 | In most deployments, you'll want to send logs to Papertrail via their [remote_syslog](http://help.papertrailapp.com/kb/configuration/configuring-centralized-logging-from-text-log-files-in-unix/) daemon, which requires no application-specific configuration. This hook is intended for relatively low-volume logging, likely in managed cloud hosting deployments where installing `remote_syslog` is not possible. 6 | 7 | ## Usage 8 | 9 | You can find your Papertrail UDP port on your [Papertrail account page](https://papertrailapp.com/account/destinations). Substitute it below for `YOUR_PAPERTRAIL_UDP_PORT`. 10 | 11 | For `YOUR_APP_NAME`, substitute a short string that will readily identify your application or service in the logs. 12 | 13 | ```go 14 | import ( 15 | "log/syslog" 16 | "github.com/Sirupsen/logrus" 17 | "github.com/Sirupsen/logrus/hooks/papertrail" 18 | ) 19 | 20 | func main() { 21 | log := logrus.New() 22 | hook, err := logrus_papertrail.NewPapertrailHook("logs.papertrailapp.com", YOUR_PAPERTRAIL_UDP_PORT, YOUR_APP_NAME) 23 | 24 | if err == nil { 25 | log.Hooks.Add(hook) 26 | } 27 | } 28 | ``` 29 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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) (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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hooks/syslog/syslog.go: -------------------------------------------------------------------------------- 1 | package logrus_syslog 2 | 3 | import ( 4 | "fmt" 5 | "github.com/Sirupsen/logrus" 6 | "log/syslog" 7 | "os" 8 | ) 9 | 10 | // SyslogHook to send logs via syslog. 11 | type SyslogHook struct { 12 | Writer *syslog.Writer 13 | SyslogNetwork string 14 | SyslogRaddr string 15 | } 16 | 17 | // Creates a hook to be added to an instance of logger. This is called with 18 | // `hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_DEBUG, "")` 19 | // `if err == nil { log.Hooks.Add(hook) }` 20 | func NewSyslogHook(network, raddr string, priority syslog.Priority, tag string) (*SyslogHook, error) { 21 | w, err := syslog.Dial(network, raddr, priority, tag) 22 | return &SyslogHook{w, network, raddr}, err 23 | } 24 | 25 | func (hook *SyslogHook) Fire(entry *logrus.Entry) error { 26 | line, err := entry.String() 27 | if err != nil { 28 | fmt.Fprintf(os.Stderr, "Unable to read entry, %v", err) 29 | return err 30 | } 31 | 32 | switch entry.Level { 33 | case logrus.PanicLevel: 34 | return hook.Writer.Crit(line) 35 | case logrus.FatalLevel: 36 | return hook.Writer.Crit(line) 37 | case logrus.ErrorLevel: 38 | return hook.Writer.Err(line) 39 | case logrus.WarnLevel: 40 | return hook.Writer.Warning(line) 41 | case logrus.InfoLevel: 42 | return hook.Writer.Info(line) 43 | case logrus.DebugLevel: 44 | return hook.Writer.Debug(line) 45 | default: 46 | return nil 47 | } 48 | } 49 | 50 | func (hook *SyslogHook) Levels() []logrus.Level { 51 | return []logrus.Level{ 52 | logrus.PanicLevel, 53 | logrus.FatalLevel, 54 | logrus.ErrorLevel, 55 | logrus.WarnLevel, 56 | logrus.InfoLevel, 57 | logrus.DebugLevel, 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /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.Mock.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/util.go: -------------------------------------------------------------------------------- 1 | package zk 2 | 3 | import ( 4 | "crypto/sha1" 5 | "encoding/base64" 6 | "fmt" 7 | "math/rand" 8 | "strconv" 9 | "strings" 10 | ) 11 | 12 | // AuthACL produces an ACL list containing a single ACL which uses the 13 | // provided permissions, with the scheme "auth", and ID "", which is used 14 | // by ZooKeeper to represent any authenticated user. 15 | func AuthACL(perms int32) []ACL { 16 | return []ACL{{perms, "auth", ""}} 17 | } 18 | 19 | // WorldACL produces an ACL list containing a single ACL which uses the 20 | // provided permissions, with the scheme "world", and ID "anyone", which 21 | // is used by ZooKeeper to represent any user at all. 22 | func WorldACL(perms int32) []ACL { 23 | return []ACL{{perms, "world", "anyone"}} 24 | } 25 | 26 | func DigestACL(perms int32, user, password string) []ACL { 27 | userPass := []byte(fmt.Sprintf("%s:%s", user, password)) 28 | h := sha1.New() 29 | if n, err := h.Write(userPass); err != nil || n != len(userPass) { 30 | panic("SHA1 failed") 31 | } 32 | digest := base64.StdEncoding.EncodeToString(h.Sum(nil)) 33 | return []ACL{{perms, "digest", fmt.Sprintf("%s:%s", user, digest)}} 34 | } 35 | 36 | // FormatServers takes a slice of addresses, and makes sure they are in a format 37 | // that resembles :. If the server has no port provided, the 38 | // DefaultPort constant is added to the end. 39 | func FormatServers(servers []string) []string { 40 | for i := range servers { 41 | if !strings.Contains(servers[i], ":") { 42 | servers[i] = servers[i] + ":" + strconv.Itoa(DefaultPort) 43 | } 44 | } 45 | return servers 46 | } 47 | 48 | // stringShuffle performs a Fisher-Yates shuffle on a slice of strings 49 | func stringShuffle(s []string) { 50 | for i := len(s) - 1; i > 0; i-- { 51 | j := rand.Intn(i + 1) 52 | s[i], s[j] = s[j], s[i] 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/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 | -------------------------------------------------------------------------------- /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 && cd testdata && make 41 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/text_formatter_test.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bytes" 5 | "errors" 6 | "testing" 7 | "time" 8 | ) 9 | 10 | func TestQuoting(t *testing.T) { 11 | tf := &TextFormatter{DisableColors: true} 12 | 13 | checkQuoting := func(q bool, value interface{}) { 14 | b, _ := tf.Format(WithField("test", value)) 15 | idx := bytes.Index(b, ([]byte)("test=")) 16 | cont := bytes.Contains(b[idx+5:], []byte{'"'}) 17 | if cont != q { 18 | if q { 19 | t.Errorf("quoting expected for: %#v", value) 20 | } else { 21 | t.Errorf("quoting not expected for: %#v", value) 22 | } 23 | } 24 | } 25 | 26 | checkQuoting(false, "abcd") 27 | checkQuoting(false, "v1.0") 28 | checkQuoting(false, "1234567890") 29 | checkQuoting(true, "/foobar") 30 | checkQuoting(true, "x y") 31 | checkQuoting(true, "x,y") 32 | checkQuoting(false, errors.New("invalid")) 33 | checkQuoting(true, errors.New("invalid argument")) 34 | } 35 | 36 | func TestTimestampFormat(t *testing.T) { 37 | checkTimeStr := func(format string) { 38 | customFormatter := &TextFormatter{DisableColors: true, TimestampFormat: format} 39 | customStr, _ := customFormatter.Format(WithField("test", "test")) 40 | timeStart := bytes.Index(customStr, ([]byte)("time=")) 41 | timeEnd := bytes.Index(customStr, ([]byte)("level=")) 42 | timeStr := customStr[timeStart+5 : timeEnd-1] 43 | if timeStr[0] == '"' && timeStr[len(timeStr)-1] == '"' { 44 | timeStr = timeStr[1 : len(timeStr)-1] 45 | } 46 | if format == "" { 47 | format = time.RFC3339 48 | } 49 | _, e := time.Parse(format, (string)(timeStr)) 50 | if e != nil { 51 | t.Errorf("time string \"%s\" did not match provided time format \"%s\": %s", timeStr, format, e) 52 | } 53 | } 54 | 55 | checkTimeStr("2006-01-02T15:04:05.000000000Z07:00") 56 | checkTimeStr("Mon Jan _2 15:04:05 2006") 57 | checkTimeStr("") 58 | } 59 | 60 | // TODO add tests for sorting etc., this requires a parser for the text 61 | // formatter output. 62 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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 | if u == nil { 54 | return "" 55 | } 56 | return fmt.Sprintf("%s@%s:%s", u.ID, u.Host, u.Port) 57 | } 58 | 59 | // Equal returns true if two upid is equal 60 | func (u *UPID) Equal(upid *UPID) bool { 61 | if u == nil { 62 | return upid == nil 63 | } else { 64 | return upid != nil && u.ID == upid.ID && u.Host == upid.Host && u.Port == upid.Port 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/structs_test.go: -------------------------------------------------------------------------------- 1 | package zk 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func TestEncodeDecodePacket(t *testing.T) { 9 | encodeDecodeTest(t, &requestHeader{-2, 5}) 10 | encodeDecodeTest(t, &connectResponse{1, 2, 3, nil}) 11 | encodeDecodeTest(t, &connectResponse{1, 2, 3, []byte{4, 5, 6}}) 12 | encodeDecodeTest(t, &getAclResponse{[]ACL{{12, "s", "anyone"}}, Stat{}}) 13 | encodeDecodeTest(t, &getChildrenResponse{[]string{"foo", "bar"}}) 14 | encodeDecodeTest(t, &pathWatchRequest{"path", true}) 15 | encodeDecodeTest(t, &pathWatchRequest{"path", false}) 16 | encodeDecodeTest(t, &CheckVersionRequest{"/", -1}) 17 | encodeDecodeTest(t, &multiRequest{Ops: []multiRequestOp{{multiHeader{opCheck, false, -1}, &CheckVersionRequest{"/", -1}}}}) 18 | } 19 | 20 | func encodeDecodeTest(t *testing.T, r interface{}) { 21 | buf := make([]byte, 1024) 22 | n, err := encodePacket(buf, r) 23 | if err != nil { 24 | t.Errorf("encodePacket returned non-nil error %+v\n", err) 25 | return 26 | } 27 | t.Logf("%+v %x", r, buf[:n]) 28 | r2 := reflect.New(reflect.ValueOf(r).Elem().Type()).Interface() 29 | n2, err := decodePacket(buf[:n], r2) 30 | if err != nil { 31 | t.Errorf("decodePacket returned non-nil error %+v\n", err) 32 | return 33 | } 34 | if n != n2 { 35 | t.Errorf("sizes don't match: %d != %d", n, n2) 36 | return 37 | } 38 | if !reflect.DeepEqual(r, r2) { 39 | t.Errorf("results don't match: %+v != %+v", r, r2) 40 | return 41 | } 42 | } 43 | 44 | func TestEncodeShortBuffer(t *testing.T) { 45 | buf := make([]byte, 0) 46 | _, err := encodePacket(buf, &requestHeader{1, 2}) 47 | if err != ErrShortBuffer { 48 | t.Errorf("encodePacket should return ErrShortBuffer on a short buffer instead of '%+v'", err) 49 | return 50 | } 51 | } 52 | 53 | func TestDecodeShortBuffer(t *testing.T) { 54 | buf := make([]byte, 0) 55 | _, err := decodePacket(buf, &responseHeader{}) 56 | if err != ErrShortBuffer { 57 | t.Errorf("decodePacket should return ErrShortBuffer on a short buffer instead of '%+v'", err) 58 | return 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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/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 | //Inject injects a message to the incoming queue. Must use context to 37 | //determine cancelled requests. Injection is aborted if the transport 38 | //is stopped. 39 | Inject(ctx context.Context, msg *Message) error 40 | 41 | //Install mount an handler based on incoming message name. 42 | Install(messageName string) 43 | 44 | //Start starts the transporter and returns immediately. The error chan 45 | //is never nil. 46 | Start() <-chan error 47 | 48 | //Stop kills the transporter. 49 | Stop(graceful bool) error 50 | 51 | //UPID returns the PID for transporter. 52 | UPID() *upid.UPID 53 | } 54 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/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/auth/callback" 12 | "github.com/mesos/mesos-go/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 | -------------------------------------------------------------------------------- /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 | rm -f test.pb.go 36 | protoc --gogo_out=. test.proto 37 | 38 | # The following rules are just aids to development. Not needed for typical testing. 39 | 40 | diff: regenerate 41 | hg diff test.pb.go 42 | 43 | restore: 44 | cp test.pb.go.golden test.pb.go 45 | 46 | preserve: 47 | cp test.pb.go test.pb.go.golden 48 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hooks/sentry/README.md: -------------------------------------------------------------------------------- 1 | # Sentry Hook for Logrus :walrus: 2 | 3 | [Sentry](https://getsentry.com) provides both self-hosted and hosted 4 | solutions for exception tracking. 5 | Both client and server are 6 | [open source](https://github.com/getsentry/sentry). 7 | 8 | ## Usage 9 | 10 | Every sentry application defined on the server gets a different 11 | [DSN](https://www.getsentry.com/docs/). In the example below replace 12 | `YOUR_DSN` with the one created for your application. 13 | 14 | ```go 15 | import ( 16 | "github.com/Sirupsen/logrus" 17 | "github.com/Sirupsen/logrus/hooks/sentry" 18 | ) 19 | 20 | func main() { 21 | log := logrus.New() 22 | hook, err := logrus_sentry.NewSentryHook(YOUR_DSN, []logrus.Level{ 23 | logrus.PanicLevel, 24 | logrus.FatalLevel, 25 | logrus.ErrorLevel, 26 | }) 27 | 28 | if err == nil { 29 | log.Hooks.Add(hook) 30 | } 31 | } 32 | ``` 33 | 34 | ## Special fields 35 | 36 | Some logrus fields have a special meaning in this hook, 37 | these are `server_name`, `logger` and `http_request`. 38 | When logs are sent to sentry these fields are treated differently. 39 | - `server_name` (also known as hostname) is the name of the server which 40 | is logging the event (hostname.example.com) 41 | - `logger` is the part of the application which is logging the event. 42 | In go this usually means setting it to the name of the package. 43 | - `http_request` is the in-coming request(*http.Request). The detailed request data are sent to Sentry. 44 | 45 | ## Timeout 46 | 47 | `Timeout` is the time the sentry hook will wait for a response 48 | from the sentry server. 49 | 50 | If this time elapses with no response from 51 | the server an error will be returned. 52 | 53 | If `Timeout` is set to 0 the SentryHook will not wait for a reply 54 | and will assume a correct delivery. 55 | 56 | The SentryHook has a default timeout of `100 milliseconds` when created 57 | with a call to `NewSentryHook`. This can be changed by assigning a value to the `Timeout` field: 58 | 59 | ```go 60 | hook, _ := logrus_sentry.NewSentryHook(...) 61 | hook.Timeout = 20*time.Second 62 | ``` 63 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/detector/zoo/mocked_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 zoo 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 MockConnector struct { 29 | mock.Mock 30 | } 31 | 32 | func NewMockConnector() *MockConnector { 33 | return new(MockConnector) 34 | } 35 | 36 | func (conn *MockConnector) Close() { 37 | conn.Called() 38 | } 39 | 40 | func (conn *MockConnector) 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 *MockConnector) 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 *MockConnector) 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 | -------------------------------------------------------------------------------- /Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/derekchiang/Mesos-Bitcoin-Miner", 3 | "GoVersion": "go1.4.2", 4 | "Packages": [ 5 | "./..." 6 | ], 7 | "Deps": [ 8 | { 9 | "ImportPath": "code.google.com/p/go-uuid/uuid", 10 | "Comment": "null-12", 11 | "Rev": "7dda39b2e7d5e265014674c5af696ba4186679e9" 12 | }, 13 | { 14 | "ImportPath": "github.com/Sirupsen/logrus", 15 | "Comment": "v0.8.2-12-g2a0a9a1", 16 | "Rev": "2a0a9a12ae2892ccfa9ab59c1222e9dcd29f9367" 17 | }, 18 | { 19 | "ImportPath": "github.com/gogo/protobuf/proto", 20 | "Rev": "ab6cea4a44ef42b748cd88d2d372047b75806e0c" 21 | }, 22 | { 23 | "ImportPath": "github.com/golang/glog", 24 | "Rev": "d1c4472bf2efd3826f2b5bdcc02d8416798d678c" 25 | }, 26 | { 27 | "ImportPath": "github.com/mesos/mesos-go/auth", 28 | "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c" 29 | }, 30 | { 31 | "ImportPath": "github.com/mesos/mesos-go/detector", 32 | "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c" 33 | }, 34 | { 35 | "ImportPath": "github.com/mesos/mesos-go/mesosproto", 36 | "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c" 37 | }, 38 | { 39 | "ImportPath": "github.com/mesos/mesos-go/mesosutil", 40 | "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c" 41 | }, 42 | { 43 | "ImportPath": "github.com/mesos/mesos-go/messenger", 44 | "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c" 45 | }, 46 | { 47 | "ImportPath": "github.com/mesos/mesos-go/scheduler", 48 | "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c" 49 | }, 50 | { 51 | "ImportPath": "github.com/mesos/mesos-go/upid", 52 | "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c" 53 | }, 54 | { 55 | "ImportPath": "github.com/samuel/go-zookeeper/zk", 56 | "Rev": "d0e0d8e11f318e000a8cc434616d69e329edc374" 57 | }, 58 | { 59 | "ImportPath": "github.com/stretchr/objx", 60 | "Rev": "cbeaeb16a013161a98496fad62933b1d21786672" 61 | }, 62 | { 63 | "ImportPath": "github.com/stretchr/testify/assert", 64 | "Rev": "da775f0337260efbac0fce9764cee5bd3e8c85b8" 65 | }, 66 | { 67 | "ImportPath": "github.com/stretchr/testify/mock", 68 | "Rev": "da775f0337260efbac0fce9764cee5bd3e8c85b8" 69 | }, 70 | { 71 | "ImportPath": "golang.org/x/net/context", 72 | "Rev": "1dfe7915deaf3f80b962c163b918868d8a6d8974" 73 | } 74 | ] 75 | } 76 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hooks/bugsnag/bugsnag.go: -------------------------------------------------------------------------------- 1 | package logrus_bugsnag 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/Sirupsen/logrus" 7 | "github.com/bugsnag/bugsnag-go" 8 | ) 9 | 10 | type bugsnagHook struct{} 11 | 12 | // ErrBugsnagUnconfigured is returned if NewBugsnagHook is called before 13 | // bugsnag.Configure. Bugsnag must be configured before the hook. 14 | var ErrBugsnagUnconfigured = errors.New("bugsnag must be configured before installing this logrus hook") 15 | 16 | // ErrBugsnagSendFailed indicates that the hook failed to submit an error to 17 | // bugsnag. The error was successfully generated, but `bugsnag.Notify()` 18 | // failed. 19 | type ErrBugsnagSendFailed struct { 20 | err error 21 | } 22 | 23 | func (e ErrBugsnagSendFailed) Error() string { 24 | return "failed to send error to Bugsnag: " + e.err.Error() 25 | } 26 | 27 | // NewBugsnagHook initializes a logrus hook which sends exceptions to an 28 | // exception-tracking service compatible with the Bugsnag API. Before using 29 | // this hook, you must call bugsnag.Configure(). The returned object should be 30 | // registered with a log via `AddHook()` 31 | // 32 | // Entries that trigger an Error, Fatal or Panic should now include an "error" 33 | // field to send to Bugsnag. 34 | func NewBugsnagHook() (*bugsnagHook, error) { 35 | if bugsnag.Config.APIKey == "" { 36 | return nil, ErrBugsnagUnconfigured 37 | } 38 | return &bugsnagHook{}, nil 39 | } 40 | 41 | // Fire forwards an error to Bugsnag. Given a logrus.Entry, it extracts the 42 | // "error" field (or the Message if the error isn't present) and sends it off. 43 | func (hook *bugsnagHook) Fire(entry *logrus.Entry) error { 44 | var notifyErr error 45 | err, ok := entry.Data["error"].(error) 46 | if ok { 47 | notifyErr = err 48 | } else { 49 | notifyErr = errors.New(entry.Message) 50 | } 51 | 52 | bugsnagErr := bugsnag.Notify(notifyErr) 53 | if bugsnagErr != nil { 54 | return ErrBugsnagSendFailed{bugsnagErr} 55 | } 56 | 57 | return nil 58 | } 59 | 60 | // Levels enumerates the log levels on which the error should be forwarded to 61 | // bugsnag: everything at or above the "Error" level. 62 | func (hook *bugsnagHook) Levels() []logrus.Level { 63 | return []logrus.Level{ 64 | logrus.ErrorLevel, 65 | logrus.FatalLevel, 66 | logrus.PanicLevel, 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/formatter_bench_test.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | // smallFields is a small size data set for benchmarking 9 | var smallFields = Fields{ 10 | "foo": "bar", 11 | "baz": "qux", 12 | "one": "two", 13 | "three": "four", 14 | } 15 | 16 | // largeFields is a large size data set for benchmarking 17 | var largeFields = Fields{ 18 | "foo": "bar", 19 | "baz": "qux", 20 | "one": "two", 21 | "three": "four", 22 | "five": "six", 23 | "seven": "eight", 24 | "nine": "ten", 25 | "eleven": "twelve", 26 | "thirteen": "fourteen", 27 | "fifteen": "sixteen", 28 | "seventeen": "eighteen", 29 | "nineteen": "twenty", 30 | "a": "b", 31 | "c": "d", 32 | "e": "f", 33 | "g": "h", 34 | "i": "j", 35 | "k": "l", 36 | "m": "n", 37 | "o": "p", 38 | "q": "r", 39 | "s": "t", 40 | "u": "v", 41 | "w": "x", 42 | "y": "z", 43 | "this": "will", 44 | "make": "thirty", 45 | "entries": "yeah", 46 | } 47 | 48 | func BenchmarkSmallTextFormatter(b *testing.B) { 49 | doBenchmark(b, &TextFormatter{DisableColors: true}, smallFields) 50 | } 51 | 52 | func BenchmarkLargeTextFormatter(b *testing.B) { 53 | doBenchmark(b, &TextFormatter{DisableColors: true}, largeFields) 54 | } 55 | 56 | func BenchmarkSmallColoredTextFormatter(b *testing.B) { 57 | doBenchmark(b, &TextFormatter{ForceColors: true}, smallFields) 58 | } 59 | 60 | func BenchmarkLargeColoredTextFormatter(b *testing.B) { 61 | doBenchmark(b, &TextFormatter{ForceColors: true}, largeFields) 62 | } 63 | 64 | func BenchmarkSmallJSONFormatter(b *testing.B) { 65 | doBenchmark(b, &JSONFormatter{}, smallFields) 66 | } 67 | 68 | func BenchmarkLargeJSONFormatter(b *testing.B) { 69 | doBenchmark(b, &JSONFormatter{}, largeFields) 70 | } 71 | 72 | func doBenchmark(b *testing.B, formatter Formatter, fields Fields) { 73 | entry := &Entry{ 74 | Time: time.Time{}, 75 | Level: InfoLevel, 76 | Message: "message", 77 | Data: fields, 78 | } 79 | var d []byte 80 | var err error 81 | for i := 0; i < b.N; i++ { 82 | d, err = formatter.Format(entry) 83 | if err != nil { 84 | b.Fatal(err) 85 | } 86 | b.SetBytes(int64(len(d))) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/auth/interface.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "sync" 7 | 8 | log "github.com/golang/glog" 9 | "github.com/mesos/mesos-go/auth/callback" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // SPI interface: login provider implementations support this interface, clients 14 | // do not authenticate against this directly, instead they should use Login() 15 | type Authenticatee interface { 16 | // Returns no errors if successfully authenticated, otherwise a single 17 | // error. 18 | Authenticate(ctx context.Context, handler callback.Handler) error 19 | } 20 | 21 | // Func adapter for interface: allow func's to implement the Authenticatee interface 22 | // as long as the func signature matches 23 | type AuthenticateeFunc func(ctx context.Context, handler callback.Handler) error 24 | 25 | func (f AuthenticateeFunc) Authenticate(ctx context.Context, handler callback.Handler) error { 26 | return f(ctx, handler) 27 | } 28 | 29 | var ( 30 | // Authentication was attempted and failed (likely due to incorrect credentials, too 31 | // many retries within a time window, etc). Distinctly different from authentication 32 | // errors (e.g. network errors, configuration errors, etc). 33 | AuthenticationFailed = errors.New("authentication failed") 34 | 35 | authenticateeProviders = make(map[string]Authenticatee) // authentication providers dict 36 | providerLock sync.Mutex 37 | ) 38 | 39 | // Register an authentication provider (aka "login provider"). packages that 40 | // provide Authenticatee implementations should invoke this func in their 41 | // init() to register. 42 | func RegisterAuthenticateeProvider(name string, auth Authenticatee) (err error) { 43 | providerLock.Lock() 44 | defer providerLock.Unlock() 45 | 46 | if _, found := authenticateeProviders[name]; found { 47 | err = fmt.Errorf("authentication provider already registered: %v", name) 48 | } else { 49 | authenticateeProviders[name] = auth 50 | log.V(1).Infof("registered authentication provider: %v", name) 51 | } 52 | return 53 | } 54 | 55 | // Look up an authentication provider by name, returns non-nil and true if such 56 | // a provider is found. 57 | func getAuthenticateeProvider(name string) (provider Authenticatee, ok bool) { 58 | providerLock.Lock() 59 | defer providerLock.Unlock() 60 | 61 | provider, ok = authenticateeProviders[name] 62 | return 63 | } 64 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/stretchr/objx/mutations.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | // Exclude returns a new Map with the keys in the specified []string 4 | // excluded. 5 | func (d Map) Exclude(exclude []string) Map { 6 | 7 | excluded := make(Map) 8 | for k, v := range d { 9 | var shouldInclude bool = true 10 | for _, toExclude := range exclude { 11 | if k == toExclude { 12 | shouldInclude = false 13 | break 14 | } 15 | } 16 | if shouldInclude { 17 | excluded[k] = v 18 | } 19 | } 20 | 21 | return excluded 22 | } 23 | 24 | // Copy creates a shallow copy of the Obj. 25 | func (m Map) Copy() Map { 26 | copied := make(map[string]interface{}) 27 | for k, v := range m { 28 | copied[k] = v 29 | } 30 | return New(copied) 31 | } 32 | 33 | // Merge blends the specified map with a copy of this map and returns the result. 34 | // 35 | // Keys that appear in both will be selected from the specified map. 36 | // This method requires that the wrapped object be a map[string]interface{} 37 | func (m Map) Merge(merge Map) Map { 38 | return m.Copy().MergeHere(merge) 39 | } 40 | 41 | // Merge blends the specified map with this map and returns the current map. 42 | // 43 | // Keys that appear in both will be selected from the specified map. The original map 44 | // will be modified. This method requires that 45 | // the wrapped object be a map[string]interface{} 46 | func (m Map) MergeHere(merge Map) Map { 47 | 48 | for k, v := range merge { 49 | m[k] = v 50 | } 51 | 52 | return m 53 | 54 | } 55 | 56 | // Transform builds a new Obj giving the transformer a chance 57 | // to change the keys and values as it goes. This method requires that 58 | // the wrapped object be a map[string]interface{} 59 | func (m Map) Transform(transformer func(key string, value interface{}) (string, interface{})) Map { 60 | newMap := make(map[string]interface{}) 61 | for k, v := range m { 62 | modifiedKey, modifiedVal := transformer(k, v) 63 | newMap[modifiedKey] = modifiedVal 64 | } 65 | return New(newMap) 66 | } 67 | 68 | // TransformKeys builds a new map using the specified key mapping. 69 | // 70 | // Unspecified keys will be unaltered. 71 | // This method requires that the wrapped object be a map[string]interface{} 72 | func (m Map) TransformKeys(mapping map[string]string) Map { 73 | return m.Transform(func(key string, value interface{}) (string, interface{}) { 74 | 75 | if newKey, ok := mapping[key]; ok { 76 | return newKey, value 77 | } 78 | 79 | return key, value 80 | }) 81 | } 82 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/dce.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 | "fmt" 10 | "os" 11 | ) 12 | 13 | // A Domain represents a Version 2 domain 14 | type Domain byte 15 | 16 | // Domain constants for DCE Security (Version 2) UUIDs. 17 | const ( 18 | Person = Domain(0) 19 | Group = Domain(1) 20 | Org = Domain(2) 21 | ) 22 | 23 | // NewDCESecurity returns a DCE Security (Version 2) UUID. 24 | // 25 | // The domain should be one of Person, Group or Org. 26 | // On a POSIX system the id should be the users UID for the Person 27 | // domain and the users GID for the Group. The meaning of id for 28 | // the domain Org or on non-POSIX systems is site defined. 29 | // 30 | // For a given domain/id pair the same token may be returned for up to 31 | // 7 minutes and 10 seconds. 32 | func NewDCESecurity(domain Domain, id uint32) UUID { 33 | uuid := NewUUID() 34 | if uuid != nil { 35 | uuid[6] = (uuid[6] & 0x0f) | 0x20 // Version 2 36 | uuid[9] = byte(domain) 37 | binary.BigEndian.PutUint32(uuid[0:], id) 38 | } 39 | return uuid 40 | } 41 | 42 | // NewDCEPerson returns a DCE Security (Version 2) UUID in the person 43 | // domain with the id returned by os.Getuid. 44 | // 45 | // NewDCEPerson(Person, uint32(os.Getuid())) 46 | func NewDCEPerson() UUID { 47 | return NewDCESecurity(Person, uint32(os.Getuid())) 48 | } 49 | 50 | // NewDCEGroup returns a DCE Security (Version 2) UUID in the group 51 | // domain with the id returned by os.Getgid. 52 | // 53 | // NewDCEGroup(Group, uint32(os.Getgid())) 54 | func NewDCEGroup() UUID { 55 | return NewDCESecurity(Group, uint32(os.Getgid())) 56 | } 57 | 58 | // Domain returns the domain for a Version 2 UUID or false. 59 | func (uuid UUID) Domain() (Domain, bool) { 60 | if v, _ := uuid.Version(); v != 2 { 61 | return 0, false 62 | } 63 | return Domain(uuid[9]), true 64 | } 65 | 66 | // Id returns the id for a Version 2 UUID or false. 67 | func (uuid UUID) Id() (uint32, bool) { 68 | if v, _ := uuid.Version(); v != 2 { 69 | return 0, false 70 | } 71 | return binary.BigEndian.Uint32(uuid[0:4]), true 72 | } 73 | 74 | func (d Domain) String() string { 75 | switch d { 76 | case Person: 77 | return "Person" 78 | case Group: 79 | return "Group" 80 | case Org: 81 | return "Org" 82 | } 83 | return fmt.Sprintf("Domain%d", int(d)) 84 | } 85 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/detector/zoo/mocked_detect.go: -------------------------------------------------------------------------------- 1 | package zoo 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "net/url" 7 | 8 | "github.com/gogo/protobuf/proto" 9 | log "github.com/golang/glog" 10 | util "github.com/mesos/mesos-go/mesosutil" 11 | "github.com/samuel/go-zookeeper/zk" 12 | ) 13 | 14 | type MockMasterDetector struct { 15 | *MasterDetector 16 | zkPath string 17 | conCh chan zk.Event 18 | sesCh chan zk.Event 19 | } 20 | 21 | func NewMockMasterDetector(zkurls string) (*MockMasterDetector, error) { 22 | log.V(4).Infoln("Creating mock zk master detector") 23 | md, err := NewMasterDetector(zkurls) 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | u, _ := url.Parse(zkurls) 29 | m := &MockMasterDetector{ 30 | MasterDetector: md, 31 | zkPath: u.Path, 32 | conCh: make(chan zk.Event, 5), 33 | sesCh: make(chan zk.Event, 5), 34 | } 35 | 36 | path := m.zkPath 37 | connector := NewMockConnector() 38 | connector.On("Children", path).Return([]string{"info_0", "info_5", "info_10"}, &zk.Stat{}, nil) 39 | connector.On("Get", fmt.Sprintf("%s/info_0", path)).Return(m.makeMasterInfo(), &zk.Stat{}, nil) 40 | connector.On("Close").Return(nil) 41 | connector.On("ChildrenW", m.zkPath).Return([]string{m.zkPath}, &zk.Stat{}, (<-chan zk.Event)(m.sesCh), nil) 42 | 43 | first := true 44 | m.client.setFactory(asFactory(func() (Connector, <-chan zk.Event, error) { 45 | if !first { 46 | return nil, nil, errors.New("only 1 connector allowed") 47 | } else { 48 | first = false 49 | } 50 | return connector, m.conCh, nil 51 | })) 52 | 53 | return m, nil 54 | } 55 | 56 | func (m *MockMasterDetector) Start() { 57 | m.client.connect() 58 | } 59 | 60 | func (m *MockMasterDetector) ScheduleConnEvent(s zk.State) { 61 | log.V(4).Infof("Scheduling zk connection event with state: %v\n", s) 62 | go func() { 63 | m.conCh <- zk.Event{ 64 | State: s, 65 | Path: m.zkPath, 66 | } 67 | }() 68 | } 69 | 70 | func (m *MockMasterDetector) ScheduleSessEvent(t zk.EventType) { 71 | log.V(4).Infof("Scheduling zk session event with state: %v\n", t) 72 | go func() { 73 | m.sesCh <- zk.Event{ 74 | Type: t, 75 | Path: m.zkPath, 76 | } 77 | }() 78 | } 79 | 80 | func (m *MockMasterDetector) makeMasterInfo() []byte { 81 | miPb := util.NewMasterInfo("master", 123456789, 400) 82 | miPb.Pid = proto.String("master@127.0.0.1:5050") 83 | data, err := proto.Marshal(miPb) 84 | if err != nil { 85 | panic(err) 86 | } 87 | return data 88 | } 89 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/mesosproto/state.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 | 36 | // Describes a state entry, a versioned (via a UUID) key/value pair. 37 | message Entry { 38 | required string name = 1; 39 | required bytes uuid = 2; 40 | required bytes value = 3; 41 | } 42 | 43 | 44 | // Describes an operation used in the log storage implementation. 45 | message Operation { 46 | enum Type { 47 | SNAPSHOT = 1; 48 | DIFF = 3; 49 | EXPUNGE = 2; 50 | } 51 | 52 | // Describes a "snapshot" operation. 53 | message Snapshot { 54 | required Entry entry = 1; 55 | } 56 | 57 | // Describes a "diff" operation where the 'value' of the entry is 58 | // just the diff itself, but the 'uuid' represents the UUID of the 59 | // entry after applying this diff. 60 | message Diff { 61 | required Entry entry = 1; 62 | } 63 | 64 | // Describes an "expunge" operation. 65 | message Expunge { 66 | required string name = 1; 67 | } 68 | 69 | required Type type = 1; 70 | optional Snapshot snapshot = 2; 71 | optional Diff diff = 4; 72 | optional Expunge expunge = 3; 73 | } 74 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/lock_test.go: -------------------------------------------------------------------------------- 1 | package zk 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | func TestLock(t *testing.T) { 9 | ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) 10 | if err != nil { 11 | t.Fatal(err) 12 | } 13 | defer ts.Stop() 14 | zk, _, err := ts.ConnectAll() 15 | if err != nil { 16 | t.Fatalf("Connect returned error: %+v", err) 17 | } 18 | defer zk.Close() 19 | 20 | acls := WorldACL(PermAll) 21 | 22 | l := NewLock(zk, "/test", acls) 23 | if err := l.Lock(); err != nil { 24 | t.Fatal(err) 25 | } 26 | if err := l.Unlock(); err != nil { 27 | t.Fatal(err) 28 | } 29 | 30 | val := make(chan int, 3) 31 | 32 | if err := l.Lock(); err != nil { 33 | t.Fatal(err) 34 | } 35 | 36 | l2 := NewLock(zk, "/test", acls) 37 | go func() { 38 | if err := l2.Lock(); err != nil { 39 | t.Fatal(err) 40 | } 41 | val <- 2 42 | if err := l2.Unlock(); err != nil { 43 | t.Fatal(err) 44 | } 45 | val <- 3 46 | }() 47 | time.Sleep(time.Millisecond * 100) 48 | 49 | val <- 1 50 | if err := l.Unlock(); err != nil { 51 | t.Fatal(err) 52 | } 53 | if x := <-val; x != 1 { 54 | t.Fatalf("Expected 1 instead of %d", x) 55 | } 56 | if x := <-val; x != 2 { 57 | t.Fatalf("Expected 2 instead of %d", x) 58 | } 59 | if x := <-val; x != 3 { 60 | t.Fatalf("Expected 3 instead of %d", x) 61 | } 62 | } 63 | 64 | // This tests creating a lock with a path that's more than 1 node deep (e.g. "/test-multi-level/lock"), 65 | // when a part of that path already exists (i.e. "/test-multi-level" node already exists). 66 | func TestMultiLevelLock(t *testing.T) { 67 | ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) 68 | if err != nil { 69 | t.Fatal(err) 70 | } 71 | defer ts.Stop() 72 | zk, _, err := ts.ConnectAll() 73 | if err != nil { 74 | t.Fatalf("Connect returned error: %+v", err) 75 | } 76 | defer zk.Close() 77 | 78 | acls := WorldACL(PermAll) 79 | path := "/test-multi-level" 80 | if p, err := zk.Create(path, []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { 81 | t.Fatalf("Create returned error: %+v", err) 82 | } else if p != path { 83 | t.Fatalf("Create returned different path '%s' != '%s'", p, path) 84 | } 85 | l := NewLock(zk, "/test-multi-level/lock", acls) 86 | defer zk.Delete("/test-multi-level", -1) // Clean up what we've created for this test 87 | defer zk.Delete("/test-multi-level/lock", -1) 88 | if err := l.Lock(); err != nil { 89 | t.Fatal(err) 90 | } 91 | if err := l.Unlock(); err != nil { 92 | t.Fatal(err) 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/gogo/protobuf/proto/size2_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2012 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 | package proto 33 | 34 | import ( 35 | "testing" 36 | ) 37 | 38 | // This is a separate file and package from size_test.go because that one uses 39 | // generated messages and thus may not be in package proto without having a circular 40 | // dependency, whereas this file tests unexported details of size.go. 41 | 42 | func TestVarintSize(t *testing.T) { 43 | // Check the edge cases carefully. 44 | testCases := []struct { 45 | n uint64 46 | size int 47 | }{ 48 | {0, 1}, 49 | {1, 1}, 50 | {127, 1}, 51 | {128, 2}, 52 | {16383, 2}, 53 | {16384, 3}, 54 | {1<<63 - 1, 9}, 55 | {1 << 63, 10}, 56 | } 57 | for _, tc := range testCases { 58 | size := sizeVarint(tc.n) 59 | if size != tc.size { 60 | t.Errorf("sizeVarint(%d) = %d, want %d", tc.n, size, tc.size) 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/stretchr/objx/doc.go: -------------------------------------------------------------------------------- 1 | // objx - Go package for dealing with maps, slices, JSON and other data. 2 | // 3 | // Overview 4 | // 5 | // Objx provides the `objx.Map` type, which is a `map[string]interface{}` that exposes 6 | // a powerful `Get` method (among others) that allows you to easily and quickly get 7 | // access to data within the map, without having to worry too much about type assertions, 8 | // missing data, default values etc. 9 | // 10 | // Pattern 11 | // 12 | // Objx uses a preditable pattern to make access data from within `map[string]interface{}'s 13 | // easy. 14 | // 15 | // Call one of the `objx.` functions to create your `objx.Map` to get going: 16 | // 17 | // m, err := objx.FromJSON(json) 18 | // 19 | // NOTE: Any methods or functions with the `Must` prefix will panic if something goes wrong, 20 | // the rest will be optimistic and try to figure things out without panicking. 21 | // 22 | // Use `Get` to access the value you're interested in. You can use dot and array 23 | // notation too: 24 | // 25 | // m.Get("places[0].latlng") 26 | // 27 | // Once you have saught the `Value` you're interested in, you can use the `Is*` methods 28 | // to determine its type. 29 | // 30 | // if m.Get("code").IsStr() { /* ... */ } 31 | // 32 | // Or you can just assume the type, and use one of the strong type methods to 33 | // extract the real value: 34 | // 35 | // m.Get("code").Int() 36 | // 37 | // If there's no value there (or if it's the wrong type) then a default value 38 | // will be returned, or you can be explicit about the default value. 39 | // 40 | // Get("code").Int(-1) 41 | // 42 | // If you're dealing with a slice of data as a value, Objx provides many useful 43 | // methods for iterating, manipulating and selecting that data. You can find out more 44 | // by exploring the index below. 45 | // 46 | // Reading data 47 | // 48 | // A simple example of how to use Objx: 49 | // 50 | // // use MustFromJSON to make an objx.Map from some JSON 51 | // m := objx.MustFromJSON(`{"name": "Mat", "age": 30}`) 52 | // 53 | // // get the details 54 | // name := m.Get("name").Str() 55 | // age := m.Get("age").Int() 56 | // 57 | // // get their nickname (or use their name if they 58 | // // don't have one) 59 | // nickname := m.Get("nickname").Str(name) 60 | // 61 | // Ranging 62 | // 63 | // Since `objx.Map` is a `map[string]interface{}` you can treat it as such. For 64 | // example, to `range` the data, do what you would expect: 65 | // 66 | // m := objx.MustFromJSON(json) 67 | // for key, value := range m { 68 | // 69 | // /* ... do your magic ... */ 70 | // 71 | // } 72 | package objx 73 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/stretchr/objx/fixture_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | var fixtures = []struct { 9 | // name is the name of the fixture (used for reporting 10 | // failures) 11 | name string 12 | // data is the JSON data to be worked on 13 | data string 14 | // get is the argument(s) to pass to Get 15 | get interface{} 16 | // output is the expected output 17 | output interface{} 18 | }{ 19 | { 20 | name: "Simple get", 21 | data: `{"name": "Mat"}`, 22 | get: "name", 23 | output: "Mat", 24 | }, 25 | { 26 | name: "Get with dot notation", 27 | data: `{"address": {"city": "Boulder"}}`, 28 | get: "address.city", 29 | output: "Boulder", 30 | }, 31 | { 32 | name: "Deep get with dot notation", 33 | data: `{"one": {"two": {"three": {"four": "hello"}}}}`, 34 | get: "one.two.three.four", 35 | output: "hello", 36 | }, 37 | { 38 | name: "Get missing with dot notation", 39 | data: `{"one": {"two": {"three": {"four": "hello"}}}}`, 40 | get: "one.ten", 41 | output: nil, 42 | }, 43 | { 44 | name: "Get with array notation", 45 | data: `{"tags": ["one", "two", "three"]}`, 46 | get: "tags[1]", 47 | output: "two", 48 | }, 49 | { 50 | name: "Get with array and dot notation", 51 | data: `{"types": { "tags": ["one", "two", "three"]}}`, 52 | get: "types.tags[1]", 53 | output: "two", 54 | }, 55 | { 56 | name: "Get with array and dot notation - field after array", 57 | data: `{"tags": [{"name":"one"}, {"name":"two"}, {"name":"three"}]}`, 58 | get: "tags[1].name", 59 | output: "two", 60 | }, 61 | { 62 | name: "Complex get with array and dot notation", 63 | data: `{"tags": [{"list": [{"one":"pizza"}]}]}`, 64 | get: "tags[0].list[0].one", 65 | output: "pizza", 66 | }, 67 | { 68 | name: "Get field from within string should be nil", 69 | data: `{"name":"Tyler"}`, 70 | get: "name.something", 71 | output: nil, 72 | }, 73 | { 74 | name: "Get field from within string (using array accessor) should be nil", 75 | data: `{"numbers":["one", "two", "three"]}`, 76 | get: "numbers[0].nope", 77 | output: nil, 78 | }, 79 | } 80 | 81 | func TestFixtures(t *testing.T) { 82 | 83 | for _, fixture := range fixtures { 84 | 85 | m := MustFromJSON(fixture.data) 86 | 87 | // get the value 88 | t.Logf("Running get fixture: \"%s\" (%v)", fixture.name, fixture) 89 | value := m.Get(fixture.get.(string)) 90 | 91 | // make sure it matches 92 | assert.Equal(t, fixture.output, value.data, 93 | "Get fixture \"%s\" failed: %v", fixture.name, fixture, 94 | ) 95 | 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hooks/sentry/sentry_test.go: -------------------------------------------------------------------------------- 1 | package logrus_sentry 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io/ioutil" 7 | "net/http" 8 | "net/http/httptest" 9 | "strings" 10 | "testing" 11 | 12 | "github.com/Sirupsen/logrus" 13 | "github.com/getsentry/raven-go" 14 | ) 15 | 16 | const ( 17 | message = "error message" 18 | server_name = "testserver.internal" 19 | logger_name = "test.logger" 20 | ) 21 | 22 | func getTestLogger() *logrus.Logger { 23 | l := logrus.New() 24 | l.Out = ioutil.Discard 25 | return l 26 | } 27 | 28 | func WithTestDSN(t *testing.T, tf func(string, <-chan *raven.Packet)) { 29 | pch := make(chan *raven.Packet, 1) 30 | s := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { 31 | defer req.Body.Close() 32 | d := json.NewDecoder(req.Body) 33 | p := &raven.Packet{} 34 | err := d.Decode(p) 35 | if err != nil { 36 | t.Fatal(err.Error()) 37 | } 38 | 39 | pch <- p 40 | })) 41 | defer s.Close() 42 | 43 | fragments := strings.SplitN(s.URL, "://", 2) 44 | dsn := fmt.Sprintf( 45 | "%s://public:secret@%s/sentry/project-id", 46 | fragments[0], 47 | fragments[1], 48 | ) 49 | tf(dsn, pch) 50 | } 51 | 52 | func TestSpecialFields(t *testing.T) { 53 | WithTestDSN(t, func(dsn string, pch <-chan *raven.Packet) { 54 | logger := getTestLogger() 55 | 56 | hook, err := NewSentryHook(dsn, []logrus.Level{ 57 | logrus.ErrorLevel, 58 | }) 59 | 60 | if err != nil { 61 | t.Fatal(err.Error()) 62 | } 63 | logger.Hooks.Add(hook) 64 | 65 | req, _ := http.NewRequest("GET", "url", nil) 66 | logger.WithFields(logrus.Fields{ 67 | "server_name": server_name, 68 | "logger": logger_name, 69 | "http_request": req, 70 | }).Error(message) 71 | 72 | packet := <-pch 73 | if packet.Logger != logger_name { 74 | t.Errorf("logger should have been %s, was %s", logger_name, packet.Logger) 75 | } 76 | 77 | if packet.ServerName != server_name { 78 | t.Errorf("server_name should have been %s, was %s", server_name, packet.ServerName) 79 | } 80 | }) 81 | } 82 | 83 | func TestSentryHandler(t *testing.T) { 84 | WithTestDSN(t, func(dsn string, pch <-chan *raven.Packet) { 85 | logger := getTestLogger() 86 | hook, err := NewSentryHook(dsn, []logrus.Level{ 87 | logrus.ErrorLevel, 88 | }) 89 | if err != nil { 90 | t.Fatal(err.Error()) 91 | } 92 | logger.Hooks.Add(hook) 93 | 94 | logger.Error(message) 95 | packet := <-pch 96 | if packet.Message != message { 97 | t.Errorf("message should have been %s, was %s", message, packet.Message) 98 | } 99 | }) 100 | } 101 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hook_test.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | type TestHook struct { 10 | Fired bool 11 | } 12 | 13 | func (hook *TestHook) Fire(entry *Entry) error { 14 | hook.Fired = true 15 | return nil 16 | } 17 | 18 | func (hook *TestHook) Levels() []Level { 19 | return []Level{ 20 | DebugLevel, 21 | InfoLevel, 22 | WarnLevel, 23 | ErrorLevel, 24 | FatalLevel, 25 | PanicLevel, 26 | } 27 | } 28 | 29 | func TestHookFires(t *testing.T) { 30 | hook := new(TestHook) 31 | 32 | LogAndAssertJSON(t, func(log *Logger) { 33 | log.Hooks.Add(hook) 34 | assert.Equal(t, hook.Fired, false) 35 | 36 | log.Print("test") 37 | }, func(fields Fields) { 38 | assert.Equal(t, hook.Fired, true) 39 | }) 40 | } 41 | 42 | type ModifyHook struct { 43 | } 44 | 45 | func (hook *ModifyHook) Fire(entry *Entry) error { 46 | entry.Data["wow"] = "whale" 47 | return nil 48 | } 49 | 50 | func (hook *ModifyHook) Levels() []Level { 51 | return []Level{ 52 | DebugLevel, 53 | InfoLevel, 54 | WarnLevel, 55 | ErrorLevel, 56 | FatalLevel, 57 | PanicLevel, 58 | } 59 | } 60 | 61 | func TestHookCanModifyEntry(t *testing.T) { 62 | hook := new(ModifyHook) 63 | 64 | LogAndAssertJSON(t, func(log *Logger) { 65 | log.Hooks.Add(hook) 66 | log.WithField("wow", "elephant").Print("test") 67 | }, func(fields Fields) { 68 | assert.Equal(t, fields["wow"], "whale") 69 | }) 70 | } 71 | 72 | func TestCanFireMultipleHooks(t *testing.T) { 73 | hook1 := new(ModifyHook) 74 | hook2 := new(TestHook) 75 | 76 | LogAndAssertJSON(t, func(log *Logger) { 77 | log.Hooks.Add(hook1) 78 | log.Hooks.Add(hook2) 79 | 80 | log.WithField("wow", "elephant").Print("test") 81 | }, func(fields Fields) { 82 | assert.Equal(t, fields["wow"], "whale") 83 | assert.Equal(t, hook2.Fired, true) 84 | }) 85 | } 86 | 87 | type ErrorHook struct { 88 | Fired bool 89 | } 90 | 91 | func (hook *ErrorHook) Fire(entry *Entry) error { 92 | hook.Fired = true 93 | return nil 94 | } 95 | 96 | func (hook *ErrorHook) Levels() []Level { 97 | return []Level{ 98 | ErrorLevel, 99 | } 100 | } 101 | 102 | func TestErrorHookShouldntFireOnInfo(t *testing.T) { 103 | hook := new(ErrorHook) 104 | 105 | LogAndAssertJSON(t, func(log *Logger) { 106 | log.Hooks.Add(hook) 107 | log.Info("test") 108 | }, func(fields Fields) { 109 | assert.Equal(t, hook.Fired, false) 110 | }) 111 | } 112 | 113 | func TestErrorHookShouldFireOnError(t *testing.T) { 114 | hook := new(ErrorHook) 115 | 116 | LogAndAssertJSON(t, func(log *Logger) { 117 | log.Hooks.Add(hook) 118 | log.Error("test") 119 | }, func(fields Fields) { 120 | assert.Equal(t, hook.Fired, true) 121 | }) 122 | } 123 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/logrus.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | ) 7 | 8 | // Fields type, used to pass to `WithFields`. 9 | type Fields map[string]interface{} 10 | 11 | // Level type 12 | type Level uint8 13 | 14 | // Convert the Level to a string. E.g. PanicLevel becomes "panic". 15 | func (level Level) String() string { 16 | switch level { 17 | case DebugLevel: 18 | return "debug" 19 | case InfoLevel: 20 | return "info" 21 | case WarnLevel: 22 | return "warning" 23 | case ErrorLevel: 24 | return "error" 25 | case FatalLevel: 26 | return "fatal" 27 | case PanicLevel: 28 | return "panic" 29 | } 30 | 31 | return "unknown" 32 | } 33 | 34 | // ParseLevel takes a string level and returns the Logrus log level constant. 35 | func ParseLevel(lvl string) (Level, error) { 36 | switch lvl { 37 | case "panic": 38 | return PanicLevel, nil 39 | case "fatal": 40 | return FatalLevel, nil 41 | case "error": 42 | return ErrorLevel, nil 43 | case "warn", "warning": 44 | return WarnLevel, nil 45 | case "info": 46 | return InfoLevel, nil 47 | case "debug": 48 | return DebugLevel, nil 49 | } 50 | 51 | var l Level 52 | return l, fmt.Errorf("not a valid logrus Level: %q", lvl) 53 | } 54 | 55 | // These are the different logging levels. You can set the logging level to log 56 | // on your instance of logger, obtained with `logrus.New()`. 57 | const ( 58 | // PanicLevel level, highest level of severity. Logs and then calls panic with the 59 | // message passed to Debug, Info, ... 60 | PanicLevel Level = iota 61 | // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the 62 | // logging level is set to Panic. 63 | FatalLevel 64 | // ErrorLevel level. Logs. Used for errors that should definitely be noted. 65 | // Commonly used for hooks to send errors to an error tracking service. 66 | ErrorLevel 67 | // WarnLevel level. Non-critical entries that deserve eyes. 68 | WarnLevel 69 | // InfoLevel level. General operational entries about what's going on inside the 70 | // application. 71 | InfoLevel 72 | // DebugLevel level. Usually only enabled when debugging. Very verbose logging. 73 | DebugLevel 74 | ) 75 | 76 | // Won't compile if StdLogger can't be realized by a log.Logger 77 | var _ StdLogger = &log.Logger{} 78 | 79 | // StdLogger is what your logrus-enabled library should take, that way 80 | // it'll accept a stdlib logger and a logrus logger. There's no standard 81 | // interface, this is the closest we get, unfortunately. 82 | type StdLogger interface { 83 | Print(...interface{}) 84 | Printf(string, ...interface{}) 85 | Println(...interface{}) 86 | 87 | Fatal(...interface{}) 88 | Fatalf(string, ...interface{}) 89 | Fatalln(...interface{}) 90 | 91 | Panic(...interface{}) 92 | Panicf(string, ...interface{}) 93 | Panicln(...interface{}) 94 | } 95 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/gogo/protobuf/proto/message_set_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2014 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 | package proto 33 | 34 | import ( 35 | "bytes" 36 | "testing" 37 | ) 38 | 39 | func TestUnmarshalMessageSetWithDuplicate(t *testing.T) { 40 | // Check that a repeated message set entry will be concatenated. 41 | in := &MessageSet{ 42 | Item: []*_MessageSet_Item{ 43 | {TypeId: Int32(12345), Message: []byte("hoo")}, 44 | {TypeId: Int32(12345), Message: []byte("hah")}, 45 | }, 46 | } 47 | b, err := Marshal(in) 48 | if err != nil { 49 | t.Fatalf("Marshal: %v", err) 50 | } 51 | t.Logf("Marshaled bytes: %q", b) 52 | 53 | m := make(map[int32]Extension) 54 | if err := UnmarshalMessageSet(b, m); err != nil { 55 | t.Fatalf("UnmarshalMessageSet: %v", err) 56 | } 57 | ext, ok := m[12345] 58 | if !ok { 59 | t.Fatalf("Didn't retrieve extension 12345; map is %v", m) 60 | } 61 | // Skip wire type/field number and length varints. 62 | got := skipVarint(skipVarint(ext.enc)) 63 | if want := []byte("hoohah"); !bytes.Equal(got, want) { 64 | t.Errorf("Combined extension is %q, want %q", got, want) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/mesosproto/internal.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-gogo. 2 | // source: internal.proto 3 | // DO NOT EDIT! 4 | 5 | package mesosproto 6 | 7 | import proto "github.com/gogo/protobuf/proto" 8 | import math "math" 9 | 10 | // discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb" 11 | 12 | // Reference imports to suppress errors if they are not otherwise used. 13 | var _ = proto.Marshal 14 | var _ = math.Inf 15 | 16 | // For use with detector callbacks 17 | type InternalMasterChangeDetected struct { 18 | // will be present if there's a new master, otherwise nil 19 | Master *MasterInfo `protobuf:"bytes,1,opt,name=master" json:"master,omitempty"` 20 | XXX_unrecognized []byte `json:"-"` 21 | } 22 | 23 | func (m *InternalMasterChangeDetected) Reset() { *m = InternalMasterChangeDetected{} } 24 | func (m *InternalMasterChangeDetected) String() string { return proto.CompactTextString(m) } 25 | func (*InternalMasterChangeDetected) ProtoMessage() {} 26 | 27 | func (m *InternalMasterChangeDetected) GetMaster() *MasterInfo { 28 | if m != nil { 29 | return m.Master 30 | } 31 | return nil 32 | } 33 | 34 | type InternalTryAuthentication struct { 35 | XXX_unrecognized []byte `json:"-"` 36 | } 37 | 38 | func (m *InternalTryAuthentication) Reset() { *m = InternalTryAuthentication{} } 39 | func (m *InternalTryAuthentication) String() string { return proto.CompactTextString(m) } 40 | func (*InternalTryAuthentication) ProtoMessage() {} 41 | 42 | type InternalAuthenticationResult struct { 43 | // true only if the authentication process completed and login was successful 44 | Success *bool `protobuf:"varint,1,req,name=success" json:"success,omitempty"` 45 | // true if the authentication process completed, successfully or not 46 | Completed *bool `protobuf:"varint,2,req,name=completed" json:"completed,omitempty"` 47 | // master pid that this result pertains to 48 | Pid *string `protobuf:"bytes,3,req,name=pid" json:"pid,omitempty"` 49 | XXX_unrecognized []byte `json:"-"` 50 | } 51 | 52 | func (m *InternalAuthenticationResult) Reset() { *m = InternalAuthenticationResult{} } 53 | func (m *InternalAuthenticationResult) String() string { return proto.CompactTextString(m) } 54 | func (*InternalAuthenticationResult) ProtoMessage() {} 55 | 56 | func (m *InternalAuthenticationResult) GetSuccess() bool { 57 | if m != nil && m.Success != nil { 58 | return *m.Success 59 | } 60 | return false 61 | } 62 | 63 | func (m *InternalAuthenticationResult) GetCompleted() bool { 64 | if m != nil && m.Completed != nil { 65 | return *m.Completed 66 | } 67 | return false 68 | } 69 | 70 | func (m *InternalAuthenticationResult) GetPid() string { 71 | if m != nil && m.Pid != nil { 72 | return *m.Pid 73 | } 74 | return "" 75 | } 76 | 77 | func init() { 78 | } 79 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/mesosproto/registry.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-gogo. 2 | // source: registry.proto 3 | // DO NOT EDIT! 4 | 5 | package mesosproto 6 | 7 | import proto "github.com/gogo/protobuf/proto" 8 | import math "math" 9 | 10 | // discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto/gogo.pb" 11 | 12 | // Reference imports to suppress errors if they are not otherwise used. 13 | var _ = proto.Marshal 14 | var _ = math.Inf 15 | 16 | type Registry struct { 17 | // Most recent leading master. 18 | Master *Registry_Master `protobuf:"bytes,1,opt,name=master" json:"master,omitempty"` 19 | // All admitted slaves. 20 | Slaves *Registry_Slaves `protobuf:"bytes,2,opt,name=slaves" json:"slaves,omitempty"` 21 | XXX_unrecognized []byte `json:"-"` 22 | } 23 | 24 | func (m *Registry) Reset() { *m = Registry{} } 25 | func (m *Registry) String() string { return proto.CompactTextString(m) } 26 | func (*Registry) ProtoMessage() {} 27 | 28 | func (m *Registry) GetMaster() *Registry_Master { 29 | if m != nil { 30 | return m.Master 31 | } 32 | return nil 33 | } 34 | 35 | func (m *Registry) GetSlaves() *Registry_Slaves { 36 | if m != nil { 37 | return m.Slaves 38 | } 39 | return nil 40 | } 41 | 42 | type Registry_Master struct { 43 | Info *MasterInfo `protobuf:"bytes,1,req,name=info" json:"info,omitempty"` 44 | XXX_unrecognized []byte `json:"-"` 45 | } 46 | 47 | func (m *Registry_Master) Reset() { *m = Registry_Master{} } 48 | func (m *Registry_Master) String() string { return proto.CompactTextString(m) } 49 | func (*Registry_Master) ProtoMessage() {} 50 | 51 | func (m *Registry_Master) GetInfo() *MasterInfo { 52 | if m != nil { 53 | return m.Info 54 | } 55 | return nil 56 | } 57 | 58 | type Registry_Slave struct { 59 | Info *SlaveInfo `protobuf:"bytes,1,req,name=info" json:"info,omitempty"` 60 | XXX_unrecognized []byte `json:"-"` 61 | } 62 | 63 | func (m *Registry_Slave) Reset() { *m = Registry_Slave{} } 64 | func (m *Registry_Slave) String() string { return proto.CompactTextString(m) } 65 | func (*Registry_Slave) ProtoMessage() {} 66 | 67 | func (m *Registry_Slave) GetInfo() *SlaveInfo { 68 | if m != nil { 69 | return m.Info 70 | } 71 | return nil 72 | } 73 | 74 | type Registry_Slaves struct { 75 | Slaves []*Registry_Slave `protobuf:"bytes,1,rep,name=slaves" json:"slaves,omitempty"` 76 | XXX_unrecognized []byte `json:"-"` 77 | } 78 | 79 | func (m *Registry_Slaves) Reset() { *m = Registry_Slaves{} } 80 | func (m *Registry_Slaves) String() string { return proto.CompactTextString(m) } 81 | func (*Registry_Slaves) ProtoMessage() {} 82 | 83 | func (m *Registry_Slaves) GetSlaves() []*Registry_Slave { 84 | if m != nil { 85 | return m.Slaves 86 | } 87 | return nil 88 | } 89 | 90 | func init() { 91 | } 92 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/detector/interface.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 detector 20 | 21 | import ( 22 | mesos "github.com/mesos/mesos-go/mesosproto" 23 | ) 24 | 25 | type MasterChanged interface { 26 | // Invoked when the master changes 27 | OnMasterChanged(*mesos.MasterInfo) 28 | } 29 | 30 | // AllMasters defines an optional interface that, if implemented by the same 31 | // struct as implements MasterChanged, will receive an additional callbacks 32 | // independently of leadership changes. it's possible that, as a result of a 33 | // leadership change, both the OnMasterChanged and UpdatedMasters callbacks 34 | // would be invoked. 35 | // 36 | // **NOTE:** Detector implementations are not required to support this optional 37 | // interface. Please RTFM of the detector implementation that you want to use. 38 | type AllMasters interface { 39 | // UpdatedMasters is invoked upon a change in the membership of mesos 40 | // masters, and is useful to clients that wish to know the entire set 41 | // of Mesos masters currently running. 42 | UpdatedMasters([]*mesos.MasterInfo) 43 | } 44 | 45 | // func/interface adapter 46 | type OnMasterChanged func(*mesos.MasterInfo) 47 | 48 | func (f OnMasterChanged) OnMasterChanged(mi *mesos.MasterInfo) { 49 | f(mi) 50 | } 51 | 52 | // An abstraction of a Master detector which can be used to 53 | // detect the leading master from a group. 54 | type Master interface { 55 | // Detect new master election. Every time a new master is elected, the 56 | // detector will alert the observer. The first call to Detect is expected 57 | // to kickstart any background detection processing (and not before then). 58 | // If detection startup fails, or the listener cannot be added, then an 59 | // error is returned. 60 | Detect(MasterChanged) error 61 | 62 | // returns a chan that, when closed, indicates the detector has terminated 63 | Done() <-chan struct{} 64 | 65 | // cancel the detector. it's ok to call this multiple times, or even if 66 | // Detect() hasn't been invoked yet. 67 | Cancel() 68 | } 69 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/lock.go: -------------------------------------------------------------------------------- 1 | package zk 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "strconv" 7 | "strings" 8 | ) 9 | 10 | var ( 11 | ErrDeadlock = errors.New("zk: trying to acquire a lock twice") 12 | ErrNotLocked = errors.New("zk: not locked") 13 | ) 14 | 15 | type Lock struct { 16 | c *Conn 17 | path string 18 | acl []ACL 19 | lockPath string 20 | seq int 21 | } 22 | 23 | func NewLock(c *Conn, path string, acl []ACL) *Lock { 24 | return &Lock{ 25 | c: c, 26 | path: path, 27 | acl: acl, 28 | } 29 | } 30 | 31 | func parseSeq(path string) (int, error) { 32 | parts := strings.Split(path, "-") 33 | return strconv.Atoi(parts[len(parts)-1]) 34 | } 35 | 36 | func (l *Lock) Lock() error { 37 | if l.lockPath != "" { 38 | return ErrDeadlock 39 | } 40 | 41 | prefix := fmt.Sprintf("%s/lock-", l.path) 42 | 43 | path := "" 44 | var err error 45 | for i := 0; i < 3; i++ { 46 | path, err = l.c.CreateProtectedEphemeralSequential(prefix, []byte{}, l.acl) 47 | if err == ErrNoNode { 48 | // Create parent node. 49 | parts := strings.Split(l.path, "/") 50 | pth := "" 51 | for _, p := range parts[1:] { 52 | pth += "/" + p 53 | _, err := l.c.Create(pth, []byte{}, 0, l.acl) 54 | if err != nil && err != ErrNodeExists { 55 | return err 56 | } 57 | } 58 | } else if err == nil { 59 | break 60 | } else { 61 | return err 62 | } 63 | } 64 | if err != nil { 65 | return err 66 | } 67 | 68 | seq, err := parseSeq(path) 69 | if err != nil { 70 | return err 71 | } 72 | 73 | for { 74 | children, _, err := l.c.Children(l.path) 75 | if err != nil { 76 | return err 77 | } 78 | 79 | lowestSeq := seq 80 | prevSeq := 0 81 | prevSeqPath := "" 82 | for _, p := range children { 83 | s, err := parseSeq(p) 84 | if err != nil { 85 | return err 86 | } 87 | if s < lowestSeq { 88 | lowestSeq = s 89 | } 90 | if s < seq && s > prevSeq { 91 | prevSeq = s 92 | prevSeqPath = p 93 | } 94 | } 95 | 96 | if seq == lowestSeq { 97 | // Acquired the lock 98 | break 99 | } 100 | 101 | // Wait on the node next in line for the lock 102 | _, _, ch, err := l.c.GetW(l.path + "/" + prevSeqPath) 103 | if err != nil && err != ErrNoNode { 104 | return err 105 | } else if err != nil && err == ErrNoNode { 106 | // try again 107 | continue 108 | } 109 | 110 | ev := <-ch 111 | if ev.Err != nil { 112 | return ev.Err 113 | } 114 | } 115 | 116 | l.seq = seq 117 | l.lockPath = path 118 | return nil 119 | } 120 | 121 | func (l *Lock) Unlock() error { 122 | if l.lockPath == "" { 123 | return ErrNotLocked 124 | } 125 | if err := l.c.Delete(l.lockPath, -1); err != nil { 126 | return err 127 | } 128 | l.lockPath = "" 129 | l.seq = 0 130 | return nil 131 | } 132 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/auth/login.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | 7 | "github.com/mesos/mesos-go/auth/callback" 8 | "github.com/mesos/mesos-go/upid" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | var ( 13 | // No login provider name has been specified in a context.Context 14 | NoLoginProviderName = errors.New("missing login provider name in context") 15 | ) 16 | 17 | // Main client entrypoint into the authentication APIs: clients are expected to 18 | // invoke this func with a context containing a login provider name value. 19 | // This may be written as: 20 | // providerName := ... // the user has probably configured this via some flag 21 | // handler := ... // handlers provide data like usernames and passwords 22 | // ctx := ... // obtain some initial or timed context 23 | // err := auth.Login(auth.WithLoginProvider(ctx, providerName), handler) 24 | func Login(ctx context.Context, handler callback.Handler) error { 25 | name, ok := LoginProviderFrom(ctx) 26 | if !ok { 27 | return NoLoginProviderName 28 | } 29 | provider, ok := getAuthenticateeProvider(name) 30 | if !ok { 31 | return fmt.Errorf("unrecognized login provider name in context: %s", name) 32 | } 33 | return provider.Authenticate(ctx, handler) 34 | } 35 | 36 | // Unexported key type, avoids conflicts with other context-using packages. All 37 | // context items registered from this package should use keys of this type. 38 | type loginKeyType int 39 | 40 | const ( 41 | loginProviderNameKey loginKeyType = iota // name of login provider to use 42 | parentUpidKey // upid.UPID of some parent process 43 | ) 44 | 45 | // Return a context that inherits all values from the parent ctx and specifies 46 | // the login provider name given here. Intended to be invoked before calls to 47 | // Login(). 48 | func WithLoginProvider(ctx context.Context, providerName string) context.Context { 49 | return context.WithValue(ctx, loginProviderNameKey, providerName) 50 | } 51 | 52 | // Return the name of the login provider specified in this context. 53 | func LoginProviderFrom(ctx context.Context) (name string, ok bool) { 54 | name, ok = ctx.Value(loginProviderNameKey).(string) 55 | return 56 | } 57 | 58 | // Return the name of the login provider specified in this context, or empty 59 | // string if none. 60 | func LoginProvider(ctx context.Context) string { 61 | name, _ := LoginProviderFrom(ctx) 62 | return name 63 | } 64 | 65 | func WithParentUPID(ctx context.Context, pid upid.UPID) context.Context { 66 | return context.WithValue(ctx, parentUpidKey, pid) 67 | } 68 | 69 | func ParentUPIDFrom(ctx context.Context) (pid upid.UPID, ok bool) { 70 | pid, ok = ctx.Value(parentUpidKey).(upid.UPID) 71 | return 72 | } 73 | 74 | func ParentUPID(ctx context.Context) (upid *upid.UPID) { 75 | if upid, ok := ParentUPIDFrom(ctx); ok { 76 | return &upid 77 | } else { 78 | return nil 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/mesosproto/containerizer.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 "mesos.proto"; 22 | import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 23 | 24 | 25 | /** 26 | * Encodes the launch command sent to the external containerizer 27 | * program. 28 | */ 29 | message Launch { 30 | required ContainerID container_id = 1; 31 | optional TaskInfo task_info = 2; 32 | optional ExecutorInfo executor_info = 3; 33 | optional string directory = 4; 34 | optional string user = 5; 35 | optional SlaveID slave_id = 6; 36 | optional string slave_pid = 7; 37 | optional bool checkpoint = 8; 38 | } 39 | 40 | 41 | /** 42 | * Encodes the update command sent to the external containerizer 43 | * program. 44 | */ 45 | message Update { 46 | required ContainerID container_id = 1; 47 | repeated Resource resources = 2; 48 | } 49 | 50 | 51 | /** 52 | * Encodes the wait command sent to the external containerizer 53 | * program. 54 | */ 55 | message Wait { 56 | required ContainerID container_id = 1; 57 | } 58 | 59 | 60 | /** 61 | * Encodes the destroy command sent to the external containerizer 62 | * program. 63 | */ 64 | message Destroy { 65 | required ContainerID container_id = 1; 66 | } 67 | 68 | 69 | /** 70 | * Encodes the usage command sent to the external containerizer 71 | * program. 72 | */ 73 | message Usage { 74 | required ContainerID container_id = 1; 75 | } 76 | 77 | 78 | /** 79 | * Information about a container termination, returned by the 80 | * containerizer to the slave. 81 | */ 82 | message Termination { 83 | // A container may be killed if it exceeds its resources; this will 84 | // be indicated by killed=true and described by the message string. 85 | required bool killed = 1; 86 | required string message = 2; 87 | 88 | // Exit status of the process. 89 | optional int32 status = 3; 90 | } 91 | 92 | 93 | /** 94 | * Information on all active containers returned by the containerizer 95 | * to the slave. 96 | */ 97 | message Containers { 98 | repeated ContainerID containers = 1; 99 | } 100 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/node.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 "net" 8 | 9 | var ( 10 | interfaces []net.Interface // cached list of interfaces 11 | ifname string // name of interface being used 12 | nodeID []byte // hardware for version 1 UUIDs 13 | ) 14 | 15 | // NodeInterface returns the name of the interface from which the NodeID was 16 | // derived. The interface "user" is returned if the NodeID was set by 17 | // SetNodeID. 18 | func NodeInterface() string { 19 | return ifname 20 | } 21 | 22 | // SetNodeInterface selects the hardware address to be used for Version 1 UUIDs. 23 | // If name is "" then the first usable interface found will be used or a random 24 | // Node ID will be generated. If a named interface cannot be found then false 25 | // is returned. 26 | // 27 | // SetNodeInterface never fails when name is "". 28 | func SetNodeInterface(name string) bool { 29 | if interfaces == nil { 30 | var err error 31 | interfaces, err = net.Interfaces() 32 | if err != nil && name != "" { 33 | return false 34 | } 35 | } 36 | 37 | for _, ifs := range interfaces { 38 | if len(ifs.HardwareAddr) >= 6 && (name == "" || name == ifs.Name) { 39 | if setNodeID(ifs.HardwareAddr) { 40 | ifname = ifs.Name 41 | return true 42 | } 43 | } 44 | } 45 | 46 | // We found no interfaces with a valid hardware address. If name 47 | // does not specify a specific interface generate a random Node ID 48 | // (section 4.1.6) 49 | if name == "" { 50 | if nodeID == nil { 51 | nodeID = make([]byte, 6) 52 | } 53 | randomBits(nodeID) 54 | return true 55 | } 56 | return false 57 | } 58 | 59 | // NodeID returns a slice of a copy of the current Node ID, setting the Node ID 60 | // if not already set. 61 | func NodeID() []byte { 62 | if nodeID == nil { 63 | SetNodeInterface("") 64 | } 65 | nid := make([]byte, 6) 66 | copy(nid, nodeID) 67 | return nid 68 | } 69 | 70 | // SetNodeID sets the Node ID to be used for Version 1 UUIDs. The first 6 bytes 71 | // of id are used. If id is less than 6 bytes then false is returned and the 72 | // Node ID is not set. 73 | func SetNodeID(id []byte) bool { 74 | if setNodeID(id) { 75 | ifname = "user" 76 | return true 77 | } 78 | return false 79 | } 80 | 81 | func setNodeID(id []byte) bool { 82 | if len(id) < 6 { 83 | return false 84 | } 85 | if nodeID == nil { 86 | nodeID = make([]byte, 6) 87 | } 88 | copy(nodeID, id) 89 | return true 90 | } 91 | 92 | // NodeID returns the 6 byte node id encoded in uuid. It returns nil if uuid is 93 | // not valid. The NodeID is only well defined for version 1 and 2 UUIDs. 94 | func (uuid UUID) NodeID() []byte { 95 | if len(uuid) != 16 { 96 | return nil 97 | } 98 | node := make([]byte, 6) 99 | copy(node, uuid[10:]) 100 | return node 101 | } 102 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/scheduler/schedcache.go: -------------------------------------------------------------------------------- 1 | package scheduler 2 | 3 | import ( 4 | log "github.com/golang/glog" 5 | mesos "github.com/mesos/mesos-go/mesosproto" 6 | "github.com/mesos/mesos-go/upid" 7 | "sync" 8 | ) 9 | 10 | type cachedOffer struct { 11 | offer *mesos.Offer 12 | slavePid *upid.UPID 13 | } 14 | 15 | func newCachedOffer(offer *mesos.Offer, slavePid *upid.UPID) *cachedOffer { 16 | return &cachedOffer{offer: offer, slavePid: slavePid} 17 | } 18 | 19 | // schedCache a managed cache with backing maps to store offeres 20 | // and tasked slaves. 21 | type schedCache struct { 22 | lock sync.RWMutex 23 | savedOffers map[string]*cachedOffer // current offers key:OfferID 24 | savedSlavePids map[string]*upid.UPID // Current saved slaves, key:slaveId 25 | } 26 | 27 | func newSchedCache() *schedCache { 28 | return &schedCache{ 29 | savedOffers: make(map[string]*cachedOffer), 30 | savedSlavePids: make(map[string]*upid.UPID), 31 | } 32 | } 33 | 34 | // putOffer stores an offer and the slavePID associated with offer. 35 | func (cache *schedCache) putOffer(offer *mesos.Offer, pid *upid.UPID) { 36 | if offer == nil || pid == nil { 37 | log.V(3).Infoln("WARN: Offer not cached. The offer or pid cannot be nil") 38 | return 39 | } 40 | log.V(3).Infoln("Caching offer ", offer.Id.GetValue(), " with slavePID ", pid.String()) 41 | cache.lock.Lock() 42 | cache.savedOffers[offer.Id.GetValue()] = &cachedOffer{offer: offer, slavePid: pid} 43 | cache.lock.Unlock() 44 | } 45 | 46 | // getOffer returns cached offer 47 | func (cache *schedCache) getOffer(offerId *mesos.OfferID) *cachedOffer { 48 | if offerId == nil { 49 | log.V(3).Infoln("WARN: OfferId == nil, returning nil") 50 | return nil 51 | } 52 | cache.lock.RLock() 53 | defer cache.lock.RUnlock() 54 | return cache.savedOffers[offerId.GetValue()] 55 | } 56 | 57 | // containsOff test cache for offer(offerId) 58 | func (cache *schedCache) containsOffer(offerId *mesos.OfferID) bool { 59 | cache.lock.RLock() 60 | defer cache.lock.RUnlock() 61 | _, ok := cache.savedOffers[offerId.GetValue()] 62 | return ok 63 | } 64 | 65 | func (cache *schedCache) removeOffer(offerId *mesos.OfferID) { 66 | cache.lock.Lock() 67 | delete(cache.savedOffers, offerId.GetValue()) 68 | cache.lock.Unlock() 69 | } 70 | 71 | func (cache *schedCache) putSlavePid(slaveId *mesos.SlaveID, pid *upid.UPID) { 72 | cache.lock.Lock() 73 | cache.savedSlavePids[slaveId.GetValue()] = pid 74 | cache.lock.Unlock() 75 | } 76 | 77 | func (cache *schedCache) getSlavePid(slaveId *mesos.SlaveID) *upid.UPID { 78 | if slaveId == nil { 79 | log.V(3).Infoln("SlaveId == nil, returning empty UPID") 80 | return nil 81 | } 82 | return cache.savedSlavePids[slaveId.GetValue()] 83 | } 84 | 85 | func (cache *schedCache) containsSlavePid(slaveId *mesos.SlaveID) bool { 86 | cache.lock.RLock() 87 | defer cache.lock.RUnlock() 88 | _, ok := cache.savedSlavePids[slaveId.GetValue()] 89 | return ok 90 | } 91 | 92 | func (cache *schedCache) removeSlavePid(slaveId *mesos.SlaveID) { 93 | cache.lock.Lock() 94 | delete(cache.savedSlavePids, slaveId.GetValue()) 95 | cache.lock.Unlock() 96 | } 97 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/stretchr/objx/conversions.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "bytes" 5 | "encoding/base64" 6 | "encoding/json" 7 | "errors" 8 | "fmt" 9 | "net/url" 10 | ) 11 | 12 | // JSON converts the contained object to a JSON string 13 | // representation 14 | func (m Map) JSON() (string, error) { 15 | 16 | result, err := json.Marshal(m) 17 | 18 | if err != nil { 19 | err = errors.New("objx: JSON encode failed with: " + err.Error()) 20 | } 21 | 22 | return string(result), err 23 | 24 | } 25 | 26 | // MustJSON converts the contained object to a JSON string 27 | // representation and panics if there is an error 28 | func (m Map) MustJSON() string { 29 | result, err := m.JSON() 30 | if err != nil { 31 | panic(err.Error()) 32 | } 33 | return result 34 | } 35 | 36 | // Base64 converts the contained object to a Base64 string 37 | // representation of the JSON string representation 38 | func (m Map) Base64() (string, error) { 39 | 40 | var buf bytes.Buffer 41 | 42 | jsonData, err := m.JSON() 43 | if err != nil { 44 | return "", err 45 | } 46 | 47 | encoder := base64.NewEncoder(base64.StdEncoding, &buf) 48 | encoder.Write([]byte(jsonData)) 49 | encoder.Close() 50 | 51 | return buf.String(), nil 52 | 53 | } 54 | 55 | // MustBase64 converts the contained object to a Base64 string 56 | // representation of the JSON string representation and panics 57 | // if there is an error 58 | func (m Map) MustBase64() string { 59 | result, err := m.Base64() 60 | if err != nil { 61 | panic(err.Error()) 62 | } 63 | return result 64 | } 65 | 66 | // SignedBase64 converts the contained object to a Base64 string 67 | // representation of the JSON string representation and signs it 68 | // using the provided key. 69 | func (m Map) SignedBase64(key string) (string, error) { 70 | 71 | base64, err := m.Base64() 72 | if err != nil { 73 | return "", err 74 | } 75 | 76 | sig := HashWithKey(base64, key) 77 | 78 | return base64 + SignatureSeparator + sig, nil 79 | 80 | } 81 | 82 | // MustSignedBase64 converts the contained object to a Base64 string 83 | // representation of the JSON string representation and signs it 84 | // using the provided key and panics if there is an error 85 | func (m Map) MustSignedBase64(key string) string { 86 | result, err := m.SignedBase64(key) 87 | if err != nil { 88 | panic(err.Error()) 89 | } 90 | return result 91 | } 92 | 93 | /* 94 | URL Query 95 | ------------------------------------------------ 96 | */ 97 | 98 | // URLValues creates a url.Values object from an Obj. This 99 | // function requires that the wrapped object be a map[string]interface{} 100 | func (m Map) URLValues() url.Values { 101 | 102 | vals := make(url.Values) 103 | 104 | for k, v := range m { 105 | //TODO: can this be done without sprintf? 106 | vals.Set(k, fmt.Sprintf("%v", v)) 107 | } 108 | 109 | return vals 110 | } 111 | 112 | // URLQuery gets an encoded URL query representing the given 113 | // Obj. This function requires that the wrapped object be a 114 | // map[string]interface{} 115 | func (m Map) URLQuery() (string, error) { 116 | return m.URLValues().Encode(), nil 117 | } 118 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/gogo/protobuf/proto/testdata/golden_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2012 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 | // Verify that the compiler output for test.proto is unchanged. 33 | 34 | package testdata 35 | 36 | import ( 37 | "crypto/sha1" 38 | "fmt" 39 | "io/ioutil" 40 | "os" 41 | "os/exec" 42 | "path/filepath" 43 | "testing" 44 | ) 45 | 46 | // sum returns in string form (for easy comparison) the SHA-1 hash of the named file. 47 | func sum(t *testing.T, name string) string { 48 | data, err := ioutil.ReadFile(name) 49 | if err != nil { 50 | t.Fatal(err) 51 | } 52 | t.Logf("sum(%q): length is %d", name, len(data)) 53 | hash := sha1.New() 54 | _, err = hash.Write(data) 55 | if err != nil { 56 | t.Fatal(err) 57 | } 58 | return fmt.Sprintf("% x", hash.Sum(nil)) 59 | } 60 | 61 | func run(t *testing.T, name string, args ...string) { 62 | cmd := exec.Command(name, args...) 63 | cmd.Stdin = os.Stdin 64 | cmd.Stdout = os.Stdout 65 | cmd.Stderr = os.Stderr 66 | err := cmd.Run() 67 | if err != nil { 68 | t.Fatal(err) 69 | } 70 | } 71 | 72 | func TestGolden(t *testing.T) { 73 | // Compute the original checksum. 74 | goldenSum := sum(t, "test.pb.go") 75 | // Run the proto compiler. 76 | run(t, "protoc", "--gogo_out="+os.TempDir(), "test.proto") 77 | newFile := filepath.Join(os.TempDir(), "test.pb.go") 78 | defer os.Remove(newFile) 79 | // Compute the new checksum. 80 | newSum := sum(t, newFile) 81 | // Verify 82 | if newSum != goldenSum { 83 | run(t, "diff", "-u", "test.pb.go", newFile) 84 | t.Fatal("Code generated by protoc-gen-go has changed; update test.pb.go") 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/server_help.go: -------------------------------------------------------------------------------- 1 | package zk 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "io/ioutil" 7 | "math/rand" 8 | "os" 9 | "path/filepath" 10 | "time" 11 | ) 12 | 13 | type TestServer struct { 14 | Port int 15 | Path string 16 | Srv *Server 17 | } 18 | 19 | type TestCluster struct { 20 | Path string 21 | Servers []TestServer 22 | } 23 | 24 | func StartTestCluster(size int, stdout, stderr io.Writer) (*TestCluster, error) { 25 | tmpPath, err := ioutil.TempDir("", "gozk") 26 | if err != nil { 27 | return nil, err 28 | } 29 | success := false 30 | startPort := int(rand.Int31n(6000) + 10000) 31 | cluster := &TestCluster{Path: tmpPath} 32 | defer func() { 33 | if !success { 34 | cluster.Stop() 35 | } 36 | }() 37 | for serverN := 0; serverN < size; serverN++ { 38 | srvPath := filepath.Join(tmpPath, fmt.Sprintf("srv%d", serverN)) 39 | if err := os.Mkdir(srvPath, 0700); err != nil { 40 | return nil, err 41 | } 42 | port := startPort + serverN*3 43 | cfg := ServerConfig{ 44 | ClientPort: port, 45 | DataDir: srvPath, 46 | } 47 | for i := 0; i < size; i++ { 48 | cfg.Servers = append(cfg.Servers, ServerConfigServer{ 49 | ID: i + 1, 50 | Host: "127.0.0.1", 51 | PeerPort: startPort + i*3 + 1, 52 | LeaderElectionPort: startPort + i*3 + 2, 53 | }) 54 | } 55 | cfgPath := filepath.Join(srvPath, "zoo.cfg") 56 | fi, err := os.Create(cfgPath) 57 | if err != nil { 58 | return nil, err 59 | } 60 | err = cfg.Marshall(fi) 61 | fi.Close() 62 | if err != nil { 63 | return nil, err 64 | } 65 | 66 | fi, err = os.Create(filepath.Join(srvPath, "myid")) 67 | if err != nil { 68 | return nil, err 69 | } 70 | _, err = fmt.Fprintf(fi, "%d\n", serverN+1) 71 | fi.Close() 72 | if err != nil { 73 | return nil, err 74 | } 75 | 76 | srv := &Server{ 77 | ConfigPath: cfgPath, 78 | Stdout: stdout, 79 | Stderr: stderr, 80 | } 81 | if err := srv.Start(); err != nil { 82 | return nil, err 83 | } 84 | cluster.Servers = append(cluster.Servers, TestServer{ 85 | Path: srvPath, 86 | Port: cfg.ClientPort, 87 | Srv: srv, 88 | }) 89 | } 90 | success = true 91 | time.Sleep(time.Second) // Give the server time to become active. Should probably actually attempt to connect to verify. 92 | return cluster, nil 93 | } 94 | 95 | func (ts *TestCluster) Connect(idx int) (*Conn, error) { 96 | zk, _, err := Connect([]string{fmt.Sprintf("127.0.0.1:%d", ts.Servers[idx].Port)}, time.Second*15) 97 | return zk, err 98 | } 99 | 100 | func (ts *TestCluster) ConnectAll() (*Conn, <-chan Event, error) { 101 | return ts.ConnectAllTimeout(time.Second * 15) 102 | } 103 | 104 | func (ts *TestCluster) ConnectAllTimeout(sessionTimeout time.Duration) (*Conn, <-chan Event, error) { 105 | hosts := make([]string, len(ts.Servers)) 106 | for i, srv := range ts.Servers { 107 | hosts[i] = fmt.Sprintf("127.0.0.1:%d", srv.Port) 108 | } 109 | zk, ch, err := Connect(hosts, sessionTimeout) 110 | return zk, ch, err 111 | } 112 | 113 | func (ts *TestCluster) Stop() error { 114 | for _, srv := range ts.Servers { 115 | srv.Srv.Stop() 116 | } 117 | defer os.RemoveAll(ts.Path) 118 | return nil 119 | } 120 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/auth/sasl/authenticatee_test.go: -------------------------------------------------------------------------------- 1 | package sasl 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | 7 | "github.com/gogo/protobuf/proto" 8 | "github.com/mesos/mesos-go/auth/callback" 9 | "github.com/mesos/mesos-go/auth/sasl/mech/crammd5" 10 | mesos "github.com/mesos/mesos-go/mesosproto" 11 | "github.com/mesos/mesos-go/messenger" 12 | "github.com/mesos/mesos-go/upid" 13 | "github.com/stretchr/testify/assert" 14 | "github.com/stretchr/testify/mock" 15 | "golang.org/x/net/context" 16 | ) 17 | 18 | type MockTransport struct { 19 | *messenger.MockedMessenger 20 | } 21 | 22 | func (m *MockTransport) Send(ctx context.Context, upid *upid.UPID, msg proto.Message) error { 23 | return m.Called(mock.Anything, upid, msg).Error(0) 24 | } 25 | 26 | func TestAuthticatee_validLogin(t *testing.T) { 27 | assert := assert.New(t) 28 | ctx := context.TODO() 29 | client := upid.UPID{ 30 | ID: "someFramework", 31 | Host: "b.net", 32 | Port: "789", 33 | } 34 | server := upid.UPID{ 35 | ID: "serv", 36 | Host: "a.com", 37 | Port: "123", 38 | } 39 | tpid := upid.UPID{ 40 | ID: "sasl_transport", 41 | Host: "g.org", 42 | Port: "456", 43 | } 44 | handler := callback.HandlerFunc(func(cb ...callback.Interface) error { 45 | for _, c := range cb { 46 | switch c := c.(type) { 47 | case *callback.Name: 48 | c.Set("foo") 49 | case *callback.Password: 50 | c.Set([]byte("bar")) 51 | case *callback.Interprocess: 52 | c.Set(server, client) 53 | default: 54 | return &callback.Unsupported{Callback: c} 55 | } 56 | } 57 | return nil 58 | }) 59 | var transport *MockTransport 60 | factory := transportFactoryFunc(func() messenger.Messenger { 61 | transport = &MockTransport{messenger.NewMockedMessenger()} 62 | transport.On("Install").Return(nil) 63 | transport.On("UPID").Return(&tpid) 64 | transport.On("Start").Return(nil) 65 | transport.On("Stop").Return(nil) 66 | transport.On("Send", mock.Anything, &server, &mesos.AuthenticateMessage{ 67 | Pid: proto.String(client.String()), 68 | }).Return(nil).Run(func(_ mock.Arguments) { 69 | transport.Recv(&server, &mesos.AuthenticationMechanismsMessage{ 70 | Mechanisms: []string{crammd5.Name}, 71 | }) 72 | }).Once() 73 | 74 | transport.On("Send", mock.Anything, &server, &mesos.AuthenticationStartMessage{ 75 | Mechanism: proto.String(crammd5.Name), 76 | Data: proto.String(""), // may be nil, depends on init step 77 | }).Return(nil).Run(func(_ mock.Arguments) { 78 | transport.Recv(&server, &mesos.AuthenticationStepMessage{ 79 | Data: []byte(`lsd;lfkgjs;dlfkgjs;dfklg`), 80 | }) 81 | }).Once() 82 | 83 | transport.On("Send", mock.Anything, &server, &mesos.AuthenticationStepMessage{ 84 | Data: []byte(`foo cc7fd96cd80123ea844a7dba29a594ed`), 85 | }).Return(nil).Run(func(_ mock.Arguments) { 86 | transport.Recv(&server, &mesos.AuthenticationCompletedMessage{}) 87 | }).Once() 88 | 89 | return transport 90 | }) 91 | login, err := makeAuthenticatee(handler, factory) 92 | assert.Nil(err) 93 | 94 | err = login.Authenticate(ctx, handler) 95 | assert.Nil(err) 96 | assert.NotNil(transport) 97 | time.Sleep(1 * time.Second) // wait for the authenticator to shut down 98 | transport.AssertExpectations(t) 99 | } 100 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/json_formatter_test.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "errors" 6 | 7 | "testing" 8 | ) 9 | 10 | func TestErrorNotLost(t *testing.T) { 11 | formatter := &JSONFormatter{} 12 | 13 | b, err := formatter.Format(WithField("error", errors.New("wild walrus"))) 14 | if err != nil { 15 | t.Fatal("Unable to format entry: ", err) 16 | } 17 | 18 | entry := make(map[string]interface{}) 19 | err = json.Unmarshal(b, &entry) 20 | if err != nil { 21 | t.Fatal("Unable to unmarshal formatted entry: ", err) 22 | } 23 | 24 | if entry["error"] != "wild walrus" { 25 | t.Fatal("Error field not set") 26 | } 27 | } 28 | 29 | func TestErrorNotLostOnFieldNotNamedError(t *testing.T) { 30 | formatter := &JSONFormatter{} 31 | 32 | b, err := formatter.Format(WithField("omg", errors.New("wild walrus"))) 33 | if err != nil { 34 | t.Fatal("Unable to format entry: ", err) 35 | } 36 | 37 | entry := make(map[string]interface{}) 38 | err = json.Unmarshal(b, &entry) 39 | if err != nil { 40 | t.Fatal("Unable to unmarshal formatted entry: ", err) 41 | } 42 | 43 | if entry["omg"] != "wild walrus" { 44 | t.Fatal("Error field not set") 45 | } 46 | } 47 | 48 | func TestFieldClashWithTime(t *testing.T) { 49 | formatter := &JSONFormatter{} 50 | 51 | b, err := formatter.Format(WithField("time", "right now!")) 52 | if err != nil { 53 | t.Fatal("Unable to format entry: ", err) 54 | } 55 | 56 | entry := make(map[string]interface{}) 57 | err = json.Unmarshal(b, &entry) 58 | if err != nil { 59 | t.Fatal("Unable to unmarshal formatted entry: ", err) 60 | } 61 | 62 | if entry["fields.time"] != "right now!" { 63 | t.Fatal("fields.time not set to original time field") 64 | } 65 | 66 | if entry["time"] != "0001-01-01T00:00:00Z" { 67 | t.Fatal("time field not set to current time, was: ", entry["time"]) 68 | } 69 | } 70 | 71 | func TestFieldClashWithMsg(t *testing.T) { 72 | formatter := &JSONFormatter{} 73 | 74 | b, err := formatter.Format(WithField("msg", "something")) 75 | if err != nil { 76 | t.Fatal("Unable to format entry: ", err) 77 | } 78 | 79 | entry := make(map[string]interface{}) 80 | err = json.Unmarshal(b, &entry) 81 | if err != nil { 82 | t.Fatal("Unable to unmarshal formatted entry: ", err) 83 | } 84 | 85 | if entry["fields.msg"] != "something" { 86 | t.Fatal("fields.msg not set to original msg field") 87 | } 88 | } 89 | 90 | func TestFieldClashWithLevel(t *testing.T) { 91 | formatter := &JSONFormatter{} 92 | 93 | b, err := formatter.Format(WithField("level", "something")) 94 | if err != nil { 95 | t.Fatal("Unable to format entry: ", err) 96 | } 97 | 98 | entry := make(map[string]interface{}) 99 | err = json.Unmarshal(b, &entry) 100 | if err != nil { 101 | t.Fatal("Unable to unmarshal formatted entry: ", err) 102 | } 103 | 104 | if entry["fields.level"] != "something" { 105 | t.Fatal("fields.level not set to original level field") 106 | } 107 | } 108 | 109 | func TestJSONEntryEndsWithNewline(t *testing.T) { 110 | formatter := &JSONFormatter{} 111 | 112 | b, err := formatter.Format(WithField("level", "something")) 113 | if err != nil { 114 | t.Fatal("Unable to format entry: ", err) 115 | } 116 | 117 | if b[len(b)-1] != '\n' { 118 | t.Fatal("Expected JSON log entry to end with a newline") 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/stretchr/objx/map_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | type Convertable struct { 9 | name string 10 | } 11 | 12 | func (c *Convertable) MSI() map[string]interface{} { 13 | return map[string]interface{}{"name": c.name} 14 | } 15 | 16 | type Unconvertable struct { 17 | name string 18 | } 19 | 20 | func TestMapCreation(t *testing.T) { 21 | 22 | o := New(nil) 23 | assert.Nil(t, o) 24 | 25 | o = New("Tyler") 26 | assert.Nil(t, o) 27 | 28 | unconvertable := &Unconvertable{name: "Tyler"} 29 | o = New(unconvertable) 30 | assert.Nil(t, o) 31 | 32 | convertable := &Convertable{name: "Tyler"} 33 | o = New(convertable) 34 | if assert.NotNil(t, convertable) { 35 | assert.Equal(t, "Tyler", o["name"], "Tyler") 36 | } 37 | 38 | o = MSI() 39 | if assert.NotNil(t, o) { 40 | assert.NotNil(t, o) 41 | } 42 | 43 | o = MSI("name", "Tyler") 44 | if assert.NotNil(t, o) { 45 | if assert.NotNil(t, o) { 46 | assert.Equal(t, o["name"], "Tyler") 47 | } 48 | } 49 | 50 | } 51 | 52 | func TestMapMustFromJSONWithError(t *testing.T) { 53 | 54 | _, err := FromJSON(`"name":"Mat"}`) 55 | assert.Error(t, err) 56 | 57 | } 58 | 59 | func TestMapFromJSON(t *testing.T) { 60 | 61 | o := MustFromJSON(`{"name":"Mat"}`) 62 | 63 | if assert.NotNil(t, o) { 64 | if assert.NotNil(t, o) { 65 | assert.Equal(t, "Mat", o["name"]) 66 | } 67 | } 68 | 69 | } 70 | 71 | func TestMapFromJSONWithError(t *testing.T) { 72 | 73 | var m Map 74 | 75 | assert.Panics(t, func() { 76 | m = MustFromJSON(`"name":"Mat"}`) 77 | }) 78 | 79 | assert.Nil(t, m) 80 | 81 | } 82 | 83 | func TestMapFromBase64String(t *testing.T) { 84 | 85 | base64String := "eyJuYW1lIjoiTWF0In0=" 86 | 87 | o, err := FromBase64(base64String) 88 | 89 | if assert.NoError(t, err) { 90 | assert.Equal(t, o.Get("name").Str(), "Mat") 91 | } 92 | 93 | assert.Equal(t, MustFromBase64(base64String).Get("name").Str(), "Mat") 94 | 95 | } 96 | 97 | func TestMapFromBase64StringWithError(t *testing.T) { 98 | 99 | base64String := "eyJuYW1lIjoiTWFasd0In0=" 100 | 101 | _, err := FromBase64(base64String) 102 | 103 | assert.Error(t, err) 104 | 105 | assert.Panics(t, func() { 106 | MustFromBase64(base64String) 107 | }) 108 | 109 | } 110 | 111 | func TestMapFromSignedBase64String(t *testing.T) { 112 | 113 | base64String := "eyJuYW1lIjoiTWF0In0=_67ee82916f90b2c0d68c903266e8998c9ef0c3d6" 114 | 115 | o, err := FromSignedBase64(base64String, "key") 116 | 117 | if assert.NoError(t, err) { 118 | assert.Equal(t, o.Get("name").Str(), "Mat") 119 | } 120 | 121 | assert.Equal(t, MustFromSignedBase64(base64String, "key").Get("name").Str(), "Mat") 122 | 123 | } 124 | 125 | func TestMapFromSignedBase64StringWithError(t *testing.T) { 126 | 127 | base64String := "eyJuYW1lasdIjoiTWF0In0=_67ee82916f90b2c0d68c903266e8998c9ef0c3d6" 128 | 129 | _, err := FromSignedBase64(base64String, "key") 130 | 131 | assert.Error(t, err) 132 | 133 | assert.Panics(t, func() { 134 | MustFromSignedBase64(base64String, "key") 135 | }) 136 | 137 | } 138 | 139 | func TestMapFromURLQuery(t *testing.T) { 140 | 141 | m, err := FromURLQuery("name=tyler&state=UT") 142 | if assert.NoError(t, err) && assert.NotNil(t, m) { 143 | assert.Equal(t, "tyler", m.Get("name").Str()) 144 | assert.Equal(t, "UT", m.Get("state").Str()) 145 | } 146 | 147 | } 148 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mesos/mesos-go/messenger/mocked_messenger.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 | "reflect" 23 | 24 | "github.com/gogo/protobuf/proto" 25 | "github.com/mesos/mesos-go/upid" 26 | "github.com/stretchr/testify/mock" 27 | "golang.org/x/net/context" 28 | ) 29 | 30 | type message struct { 31 | from *upid.UPID 32 | msg proto.Message 33 | } 34 | 35 | // MockedMessenger is a messenger that returns error on every operation. 36 | type MockedMessenger struct { 37 | mock.Mock 38 | messageQueue chan *message 39 | handlers map[string]MessageHandler 40 | stop chan struct{} 41 | } 42 | 43 | // NewMockedMessenger returns a mocked messenger used for testing. 44 | func NewMockedMessenger() *MockedMessenger { 45 | return &MockedMessenger{ 46 | messageQueue: make(chan *message, 1), 47 | handlers: make(map[string]MessageHandler), 48 | stop: make(chan struct{}), 49 | } 50 | } 51 | 52 | // Install is a mocked implementation. 53 | func (m *MockedMessenger) Install(handler MessageHandler, msg proto.Message) error { 54 | m.handlers[reflect.TypeOf(msg).Elem().Name()] = handler 55 | return m.Called().Error(0) 56 | } 57 | 58 | // Send is a mocked implementation. 59 | func (m *MockedMessenger) Send(ctx context.Context, upid *upid.UPID, msg proto.Message) error { 60 | return m.Called().Error(0) 61 | } 62 | 63 | func (m *MockedMessenger) Route(ctx context.Context, upid *upid.UPID, msg proto.Message) error { 64 | return m.Called().Error(0) 65 | } 66 | 67 | // Start is a mocked implementation. 68 | func (m *MockedMessenger) Start() error { 69 | go m.recvLoop() 70 | return m.Called().Error(0) 71 | } 72 | 73 | // Stop is a mocked implementation. 74 | func (m *MockedMessenger) Stop() error { 75 | // don't close an already-closed channel 76 | select { 77 | case <-m.stop: 78 | // noop 79 | default: 80 | close(m.stop) 81 | } 82 | return m.Called().Error(0) 83 | } 84 | 85 | // UPID is a mocked implementation. 86 | func (m *MockedMessenger) UPID() *upid.UPID { 87 | return m.Called().Get(0).(*upid.UPID) 88 | } 89 | 90 | func (m *MockedMessenger) recvLoop() { 91 | for { 92 | select { 93 | case <-m.stop: 94 | return 95 | case msg := <-m.messageQueue: 96 | name := reflect.TypeOf(msg.msg).Elem().Name() 97 | m.handlers[name](msg.from, msg.msg) 98 | } 99 | } 100 | } 101 | 102 | // Recv receives a upid and a message, it will dispatch the message to its handler 103 | // with the upid. This is for testing. 104 | func (m *MockedMessenger) Recv(from *upid.UPID, msg proto.Message) { 105 | m.messageQueue <- &message{from, msg} 106 | } 107 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/Sirupsen/logrus/hooks/sentry/sentry.go: -------------------------------------------------------------------------------- 1 | package logrus_sentry 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | "net/http" 7 | 8 | "github.com/Sirupsen/logrus" 9 | "github.com/getsentry/raven-go" 10 | ) 11 | 12 | var ( 13 | severityMap = map[logrus.Level]raven.Severity{ 14 | logrus.DebugLevel: raven.DEBUG, 15 | logrus.InfoLevel: raven.INFO, 16 | logrus.WarnLevel: raven.WARNING, 17 | logrus.ErrorLevel: raven.ERROR, 18 | logrus.FatalLevel: raven.FATAL, 19 | logrus.PanicLevel: raven.FATAL, 20 | } 21 | ) 22 | 23 | func getAndDel(d logrus.Fields, key string) (string, bool) { 24 | var ( 25 | ok bool 26 | v interface{} 27 | val string 28 | ) 29 | if v, ok = d[key]; !ok { 30 | return "", false 31 | } 32 | 33 | if val, ok = v.(string); !ok { 34 | return "", false 35 | } 36 | delete(d, key) 37 | return val, true 38 | } 39 | 40 | func getAndDelRequest(d logrus.Fields, key string) (*http.Request, bool) { 41 | var ( 42 | ok bool 43 | v interface{} 44 | req *http.Request 45 | ) 46 | if v, ok = d[key]; !ok { 47 | return nil, false 48 | } 49 | if req, ok = v.(*http.Request); !ok || req == nil { 50 | return nil, false 51 | } 52 | delete(d, key) 53 | return req, true 54 | } 55 | 56 | // SentryHook delivers logs to a sentry server. 57 | type SentryHook struct { 58 | // Timeout sets the time to wait for a delivery error from the sentry server. 59 | // If this is set to zero the server will not wait for any response and will 60 | // consider the message correctly sent 61 | Timeout time.Duration 62 | 63 | client *raven.Client 64 | levels []logrus.Level 65 | } 66 | 67 | // NewSentryHook creates a hook to be added to an instance of logger 68 | // and initializes the raven client. 69 | // This method sets the timeout to 100 milliseconds. 70 | func NewSentryHook(DSN string, levels []logrus.Level) (*SentryHook, error) { 71 | client, err := raven.NewClient(DSN, nil) 72 | if err != nil { 73 | return nil, err 74 | } 75 | return &SentryHook{100 * time.Millisecond, client, levels}, nil 76 | } 77 | 78 | // Called when an event should be sent to sentry 79 | // Special fields that sentry uses to give more information to the server 80 | // are extracted from entry.Data (if they are found) 81 | // These fields are: logger, server_name and http_request 82 | func (hook *SentryHook) Fire(entry *logrus.Entry) error { 83 | packet := &raven.Packet{ 84 | Message: entry.Message, 85 | Timestamp: raven.Timestamp(entry.Time), 86 | Level: severityMap[entry.Level], 87 | Platform: "go", 88 | } 89 | 90 | d := entry.Data 91 | 92 | if logger, ok := getAndDel(d, "logger"); ok { 93 | packet.Logger = logger 94 | } 95 | if serverName, ok := getAndDel(d, "server_name"); ok { 96 | packet.ServerName = serverName 97 | } 98 | if req, ok := getAndDelRequest(d, "http_request"); ok { 99 | packet.Interfaces = append(packet.Interfaces, raven.NewHttp(req)) 100 | } 101 | packet.Extra = map[string]interface{}(d) 102 | 103 | _, errCh := hook.client.Capture(packet, nil) 104 | timeout := hook.Timeout 105 | if timeout != 0 { 106 | timeoutCh := time.After(timeout) 107 | select { 108 | case err := <-errCh: 109 | return err 110 | case <-timeoutCh: 111 | return fmt.Errorf("no response from sentry server in %s", timeout) 112 | } 113 | } 114 | return nil 115 | } 116 | 117 | // Levels returns the available logging levels. 118 | func (hook *SentryHook) Levels() []logrus.Level { 119 | return hook.levels 120 | } 121 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/gogo/protobuf/proto/skip_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 | "io" 32 | ) 33 | 34 | func Skip(data []byte) (n int, err error) { 35 | l := len(data) 36 | index := 0 37 | for index < l { 38 | var wire uint64 39 | for shift := uint(0); ; shift += 7 { 40 | if index >= l { 41 | return 0, io.ErrUnexpectedEOF 42 | } 43 | b := data[index] 44 | index++ 45 | wire |= (uint64(b) & 0x7F) << shift 46 | if b < 0x80 { 47 | break 48 | } 49 | } 50 | wireType := int(wire & 0x7) 51 | switch wireType { 52 | case 0: 53 | for { 54 | if index >= l { 55 | return 0, io.ErrUnexpectedEOF 56 | } 57 | index++ 58 | if data[index-1] < 0x80 { 59 | break 60 | } 61 | } 62 | return index, nil 63 | case 1: 64 | index += 8 65 | return index, nil 66 | case 2: 67 | var length int 68 | for shift := uint(0); ; shift += 7 { 69 | if index >= l { 70 | return 0, io.ErrUnexpectedEOF 71 | } 72 | b := data[index] 73 | index++ 74 | length |= (int(b) & 0x7F) << shift 75 | if b < 0x80 { 76 | break 77 | } 78 | } 79 | index += length 80 | return index, nil 81 | case 3: 82 | for { 83 | var wire uint64 84 | var start int = index 85 | for shift := uint(0); ; shift += 7 { 86 | if index >= l { 87 | return 0, io.ErrUnexpectedEOF 88 | } 89 | b := data[index] 90 | index++ 91 | wire |= (uint64(b) & 0x7F) << shift 92 | if b < 0x80 { 93 | break 94 | } 95 | } 96 | wireType := int(wire & 0x7) 97 | if wireType == 4 { 98 | break 99 | } 100 | next, err := Skip(data[start:]) 101 | if err != nil { 102 | return 0, err 103 | } 104 | index = start + next 105 | } 106 | return index, nil 107 | case 4: 108 | return index, nil 109 | case 5: 110 | index += 4 111 | return index, nil 112 | default: 113 | return 0, fmt.Errorf("proto: illegal wireType %d", wireType) 114 | } 115 | } 116 | panic("unreachable") 117 | } 118 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/gogo/protobuf/proto/extensions_test.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2014 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 | package proto_test 33 | 34 | import ( 35 | "testing" 36 | 37 | pb "./testdata" 38 | "github.com/gogo/protobuf/proto" 39 | ) 40 | 41 | func TestGetExtensionsWithMissingExtensions(t *testing.T) { 42 | msg := &pb.MyMessage{} 43 | ext1 := &pb.Ext{} 44 | if err := proto.SetExtension(msg, pb.E_Ext_More, ext1); err != nil { 45 | t.Fatalf("Could not set ext1: %s", ext1) 46 | } 47 | exts, err := proto.GetExtensions(msg, []*proto.ExtensionDesc{ 48 | pb.E_Ext_More, 49 | pb.E_Ext_Text, 50 | }) 51 | if err != nil { 52 | t.Fatalf("GetExtensions() failed: %s", err) 53 | } 54 | if exts[0] != ext1 { 55 | t.Errorf("ext1 not in returned extensions: %T %v", exts[0], exts[0]) 56 | } 57 | if exts[1] != nil { 58 | t.Errorf("ext2 in returned extensions: %T %v", exts[1], exts[1]) 59 | } 60 | } 61 | 62 | func TestGetExtensionStability(t *testing.T) { 63 | check := func(m *pb.MyMessage) bool { 64 | ext1, err := proto.GetExtension(m, pb.E_Ext_More) 65 | if err != nil { 66 | t.Fatalf("GetExtension() failed: %s", err) 67 | } 68 | ext2, err := proto.GetExtension(m, pb.E_Ext_More) 69 | if err != nil { 70 | t.Fatalf("GetExtension() failed: %s", err) 71 | } 72 | return ext1 == ext2 73 | } 74 | msg := &pb.MyMessage{Count: proto.Int32(4)} 75 | ext0 := &pb.Ext{} 76 | if err := proto.SetExtension(msg, pb.E_Ext_More, ext0); err != nil { 77 | t.Fatalf("Could not set ext1: %s", ext0) 78 | } 79 | if !check(msg) { 80 | t.Errorf("GetExtension() not stable before marshaling") 81 | } 82 | bb, err := proto.Marshal(msg) 83 | if err != nil { 84 | t.Fatalf("Marshal() failed: %s", err) 85 | } 86 | msg1 := &pb.MyMessage{} 87 | err = proto.Unmarshal(bb, msg1) 88 | if err != nil { 89 | t.Fatalf("Unmarshal() failed: %s", err) 90 | } 91 | if !check(msg1) { 92 | t.Errorf("GetExtension() not stable after unmarshaling") 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk/tracer.go: -------------------------------------------------------------------------------- 1 | package zk 2 | 3 | import ( 4 | "encoding/binary" 5 | "fmt" 6 | "io" 7 | "net" 8 | "sync" 9 | ) 10 | 11 | var ( 12 | requests = make(map[int32]int32) // Map of Xid -> Opcode 13 | requestsLock = &sync.Mutex{} 14 | ) 15 | 16 | func trace(conn1, conn2 net.Conn, client bool) { 17 | defer conn1.Close() 18 | defer conn2.Close() 19 | buf := make([]byte, 10*1024) 20 | init := true 21 | for { 22 | _, err := io.ReadFull(conn1, buf[:4]) 23 | if err != nil { 24 | fmt.Println("1>", client, err) 25 | return 26 | } 27 | 28 | blen := int(binary.BigEndian.Uint32(buf[:4])) 29 | 30 | _, err = io.ReadFull(conn1, buf[4:4+blen]) 31 | if err != nil { 32 | fmt.Println("2>", client, err) 33 | return 34 | } 35 | 36 | var cr interface{} 37 | opcode := int32(-1) 38 | readHeader := true 39 | if client { 40 | if init { 41 | cr = &connectRequest{} 42 | readHeader = false 43 | } else { 44 | xid := int32(binary.BigEndian.Uint32(buf[4:8])) 45 | opcode = int32(binary.BigEndian.Uint32(buf[8:12])) 46 | requestsLock.Lock() 47 | requests[xid] = opcode 48 | requestsLock.Unlock() 49 | cr = requestStructForOp(opcode) 50 | if cr == nil { 51 | fmt.Printf("Unknown opcode %d\n", opcode) 52 | } 53 | } 54 | } else { 55 | if init { 56 | cr = &connectResponse{} 57 | readHeader = false 58 | } else { 59 | xid := int32(binary.BigEndian.Uint32(buf[4:8])) 60 | zxid := int64(binary.BigEndian.Uint64(buf[8:16])) 61 | errnum := int32(binary.BigEndian.Uint32(buf[16:20])) 62 | if xid != -1 || zxid != -1 { 63 | requestsLock.Lock() 64 | found := false 65 | opcode, found = requests[xid] 66 | if !found { 67 | opcode = 0 68 | } 69 | delete(requests, xid) 70 | requestsLock.Unlock() 71 | } else { 72 | opcode = opWatcherEvent 73 | } 74 | cr = responseStructForOp(opcode) 75 | if cr == nil { 76 | fmt.Printf("Unknown opcode %d\n", opcode) 77 | } 78 | if errnum != 0 { 79 | cr = &struct{}{} 80 | } 81 | } 82 | } 83 | opname := "." 84 | if opcode != -1 { 85 | opname = opNames[opcode] 86 | } 87 | if cr == nil { 88 | fmt.Printf("%+v %s %+v\n", client, opname, buf[4:4+blen]) 89 | } else { 90 | n := 4 91 | hdrStr := "" 92 | if readHeader { 93 | var hdr interface{} 94 | if client { 95 | hdr = &requestHeader{} 96 | } else { 97 | hdr = &responseHeader{} 98 | } 99 | if n2, err := decodePacket(buf[n:n+blen], hdr); err != nil { 100 | fmt.Println(err) 101 | } else { 102 | n += n2 103 | } 104 | hdrStr = fmt.Sprintf(" %+v", hdr) 105 | } 106 | if _, err := decodePacket(buf[n:n+blen], cr); err != nil { 107 | fmt.Println(err) 108 | } 109 | fmt.Printf("%+v %s%s %+v\n", client, opname, hdrStr, cr) 110 | } 111 | 112 | init = false 113 | 114 | written, err := conn2.Write(buf[:4+blen]) 115 | if err != nil { 116 | fmt.Println("3>", client, err) 117 | return 118 | } else if written != 4+blen { 119 | fmt.Printf("Written != read: %d != %d\n", written, blen) 120 | return 121 | } 122 | } 123 | } 124 | 125 | func handleConnection(addr string, conn net.Conn) { 126 | zkConn, err := net.Dial("tcp", addr) 127 | if err != nil { 128 | fmt.Println(err) 129 | return 130 | } 131 | go trace(conn, zkConn, true) 132 | trace(zkConn, conn, false) 133 | } 134 | 135 | func StartTracer(listenAddr, serverAddr string) { 136 | ln, err := net.Listen("tcp", listenAddr) 137 | if err != nil { 138 | panic(err) 139 | } 140 | for { 141 | conn, err := ln.Accept() 142 | if err != nil { 143 | fmt.Println(err) 144 | continue 145 | } 146 | go handleConnection(serverAddr, conn) 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mesos Bitcoin Miner 2 | 3 | A Mesos framework that mines Bitcoin. 4 | 5 | [An article was written about it.](https://dzone.com/articles/creating-a-distributed-system-in-300-lines-with-me) 6 | 7 | ## Setup 8 | 9 | To run this framework, you need to have a Bitcoin daemon (`bitcoind`) and a Mesos cluster running. 10 | 11 | ### Bitcoind 12 | 13 | There are many ways to install `bitcoind`; you should be able to easily find instructions online for your platform. For OS X, I usually just [build it from source](https://github.com/bitcoin/bitcoin/blob/master/doc/build-osx.md). 14 | 15 | In order for the Mesos cluster to talk to your `bitcoind`, you will need to configure your `bitcoind` to enable RPC. The location of the bitcoind config file is platform-specific, but for OS X it's at: 16 | 17 | /Users/${USER}/Library/Application Support/Bitcoin/bitcoin.conf 18 | 19 | If the file doesn't exist, go ahead and create it. You will need to set three fields: `rpcuser`, `rpcpassword`, and `rpcallowip`. Here is how my config file looks like: 20 | 21 | rpcuser=bitcoinrpc 22 | rpcpassword=BEBSruNHg14Tmz4D6X8qCjA22RCuoniDxovRCvPvGqS1 23 | rpcallowip=0.0.0.0/0 24 | 25 | `rpcuser` and `rpcpassword` can be arbitrary strings. 26 | 27 | Note that for the purpose of the demo, I've set `rpcallowip` to the entire IP space. This is **highly insecure**. In practice, you will most definitely want to set it to only allow for some specific IPs. 28 | 29 | Once the config file is in place, run bitcoind in server mode: 30 | 31 | bitcoind --daemon 32 | 33 | `bitcoind` will now start downloading the blockchain. The framework will not work until the entire blockchain has been downloaded. Note that the blockchain is huge, so you might need to wait a while. To check how many blocks you have downloaded so far: 34 | 35 | bitcoin-cli getblockcount 36 | 37 | ### Mesos Cluster 38 | 39 | To set up a real Mesos cluster, refer to the [official documentation](http://mesos.apache.org/documentation/latest/). 40 | 41 | To set up a local cluster using Vagrant, [this](https://github.com/everpeace/vagrant-mesos) and [this](https://github.com/mesosphere/playa-mesos) work really well. 42 | 43 | Importantly, you need to make sure that you start your Mesos slaves with the Docker containerizer enabled, since we make use of Docker images in our framework. If you start the Mesos slaves manually, you can just set the environment variable `MESOS_CONTAINERIZERS` to `docker`. Otherwise, you might need to modify the config files under `/etc/mesos`. 44 | 45 | In the end, you should obtain the IP address and port where the Mesos master is running on. They are needed to run the framework. 46 | 47 | ## Build 48 | 49 | You need to have [Go](http://golang.org/) installed. Then in this directory: 50 | 51 | go get github.com/tools/godep # only if you don't have godep installed already 52 | godep go build scheduler.go 53 | 54 | Now you should have a binary called `scheduler` inside the directory. 55 | 56 | ## Usage 57 | 58 | ./scheduler -master="
" -bitcoind_address="
" 59 | 60 | For example, in my local setup, I run: 61 | 62 | ./scheduler -master="172.31.1.11:5050" -bitcoind_address="172.31.2.1" bitcoinrpc BEBSruNHg14Tmz4D6X8qCjA22RCuoniDxovRCvPvGqS1 63 | 64 | Note that the `bitcoindAddress` is the IP address of your `bitcoind` **from the perspective of the Mesos cluster**. 65 | 66 | ## Demo 67 | 68 | http://recordit.co/4KOIUuLuqu 69 | 70 | ## Disclaimer 71 | 72 | With the rise of GPUs and ASICs, mining Bitcoin using raw CPUs has been unprofitable for the past few years. Therefore, this project is probably only useful for time travellers from 2011 or before. Although now that I think about it, Mesos didn't even exist before 2011, so even time travellers wouldn't be able to use it. Sorry guys. 73 | 74 | ## License 75 | 76 | [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0) 77 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/golang/glog/glog_file.go: -------------------------------------------------------------------------------- 1 | // Go support for leveled logs, analogous to https://code.google.com/p/google-glog/ 2 | // 3 | // Copyright 2013 Google Inc. All Rights Reserved. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | // File I/O for logs. 18 | 19 | package glog 20 | 21 | import ( 22 | "errors" 23 | "flag" 24 | "fmt" 25 | "os" 26 | "os/user" 27 | "path/filepath" 28 | "strings" 29 | "sync" 30 | "time" 31 | ) 32 | 33 | // MaxSize is the maximum size of a log file in bytes. 34 | var MaxSize uint64 = 1024 * 1024 * 1800 35 | 36 | // logDirs lists the candidate directories for new log files. 37 | var logDirs []string 38 | 39 | // If non-empty, overrides the choice of directory in which to write logs. 40 | // See createLogDirs for the full list of possible destinations. 41 | var logDir = flag.String("log_dir", "", "If non-empty, write log files in this directory") 42 | 43 | func createLogDirs() { 44 | if *logDir != "" { 45 | logDirs = append(logDirs, *logDir) 46 | } 47 | logDirs = append(logDirs, os.TempDir()) 48 | } 49 | 50 | var ( 51 | pid = os.Getpid() 52 | program = filepath.Base(os.Args[0]) 53 | host = "unknownhost" 54 | userName = "unknownuser" 55 | ) 56 | 57 | func init() { 58 | h, err := os.Hostname() 59 | if err == nil { 60 | host = shortHostname(h) 61 | } 62 | 63 | current, err := user.Current() 64 | if err == nil { 65 | userName = current.Username 66 | } 67 | 68 | // Sanitize userName since it may contain filepath separators on Windows. 69 | userName = strings.Replace(userName, `\`, "_", -1) 70 | } 71 | 72 | // shortHostname returns its argument, truncating at the first period. 73 | // For instance, given "www.google.com" it returns "www". 74 | func shortHostname(hostname string) string { 75 | if i := strings.Index(hostname, "."); i >= 0 { 76 | return hostname[:i] 77 | } 78 | return hostname 79 | } 80 | 81 | // logName returns a new log file name containing tag, with start time t, and 82 | // the name for the symlink for tag. 83 | func logName(tag string, t time.Time) (name, link string) { 84 | name = fmt.Sprintf("%s.%s.%s.log.%s.%04d%02d%02d-%02d%02d%02d.%d", 85 | program, 86 | host, 87 | userName, 88 | tag, 89 | t.Year(), 90 | t.Month(), 91 | t.Day(), 92 | t.Hour(), 93 | t.Minute(), 94 | t.Second(), 95 | pid) 96 | return name, program + "." + tag 97 | } 98 | 99 | var onceLogDirs sync.Once 100 | 101 | // create creates a new log file and returns the file and its filename, which 102 | // contains tag ("INFO", "FATAL", etc.) and t. If the file is created 103 | // successfully, create also attempts to update the symlink for that tag, ignoring 104 | // errors. 105 | func create(tag string, t time.Time) (f *os.File, filename string, err error) { 106 | onceLogDirs.Do(createLogDirs) 107 | if len(logDirs) == 0 { 108 | return nil, "", errors.New("log: no log dirs") 109 | } 110 | name, link := logName(tag, t) 111 | var lastErr error 112 | for _, dir := range logDirs { 113 | fname := filepath.Join(dir, name) 114 | f, err := os.Create(fname) 115 | if err == nil { 116 | symlink := filepath.Join(dir, link) 117 | os.Remove(symlink) // ignore err 118 | os.Symlink(name, symlink) // ignore err 119 | return f, fname, nil 120 | } 121 | lastErr = err 122 | } 123 | return nil, "", fmt.Errorf("log: cannot create log: %v", lastErr) 124 | } 125 | --------------------------------------------------------------------------------