github.com/m3db/m3@v1.5.0/src/cluster/integration/etcd/options.go (about) 1 // Copyright (c) 2017 Uber Technologies, Inc. 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 // THE SOFTWARE. 20 21 package etcd 22 23 import ( 24 "time" 25 26 "github.com/m3db/m3/src/x/instrument" 27 ) 28 29 const ( 30 defaulTimeout = 5 * time.Second 31 defaultDir = "etcd.dir" 32 defaultServiceID = "integration.service" 33 defaultEnv = "integration.env" 34 defaultZone = "integration.zone" 35 ) 36 37 type opts struct { 38 iopts instrument.Options 39 workingDir string 40 initTimeout time.Duration 41 serviceID string 42 env string 43 zone string 44 } 45 46 // NewOptions returns a new options 47 func NewOptions() Options { 48 return &opts{ 49 iopts: instrument.NewOptions(), 50 workingDir: defaultDir, 51 initTimeout: defaulTimeout, 52 serviceID: defaultServiceID, 53 env: defaultEnv, 54 zone: defaultZone, 55 } 56 } 57 58 func (o *opts) SetInstrumentOptions(value instrument.Options) Options { 59 oo := *o 60 oo.iopts = value 61 return &oo 62 } 63 64 func (o *opts) InstrumentOptions() instrument.Options { 65 return o.iopts 66 } 67 68 func (o *opts) SetDir(value string) Options { 69 oo := *o 70 oo.workingDir = value 71 return &oo 72 } 73 74 func (o *opts) Dir() string { 75 return o.workingDir 76 } 77 78 func (o *opts) SetInitTimeout(value time.Duration) Options { 79 oo := *o 80 oo.initTimeout = value 81 return &oo 82 } 83 84 func (o *opts) InitTimeout() time.Duration { 85 return o.initTimeout 86 } 87 88 func (o *opts) SetServiceID(value string) Options { 89 oo := *o 90 oo.serviceID = value 91 return &oo 92 } 93 94 func (o *opts) ServiceID() string { 95 return o.serviceID 96 } 97 98 func (o *opts) SetEnvironment(value string) Options { 99 oo := *o 100 oo.env = value 101 return &oo 102 } 103 104 func (o *opts) Environment() string { 105 return o.env 106 } 107 108 func (o *opts) SetZone(value string) Options { 109 oo := *o 110 oo.zone = value 111 return &oo 112 } 113 114 func (o *opts) Zone() string { 115 return o.zone 116 }