github.com/m3db/m3@v1.5.0/src/cmd/services/m3aggregator/serve/options.go (about) 1 // Copyright (c) 2020 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 serve 22 23 import ( 24 httpserver "github.com/m3db/m3/src/aggregator/server/http" 25 m3msgserver "github.com/m3db/m3/src/aggregator/server/m3msg" 26 rawtcpserver "github.com/m3db/m3/src/aggregator/server/rawtcp" 27 "github.com/m3db/m3/src/x/instrument" 28 xio "github.com/m3db/m3/src/x/io" 29 ) 30 31 // Options are aggregator options. 32 type Options interface { 33 // SetM3MsgAddr sets the M3 message address. 34 SetM3MsgAddr(value string) Options 35 36 // M3MsgAddr returns the M3 message address. 37 M3MsgAddr() string 38 39 // SetM3MsgServerOpts sets the M3MsgServerOpts. 40 SetM3MsgServerOpts(value m3msgserver.Options) Options 41 42 // M3MsgServerOpts returns the M3MsgServerOpts. 43 M3MsgServerOpts() m3msgserver.Options 44 45 // SetRawTCPAddr sets the RawTCP address. 46 SetRawTCPAddr(value string) Options 47 48 // RawTCPAddr returns the RawTCP address. 49 RawTCPAddr() string 50 51 // SetRawTCPServerOpts sets the RawTCPServerOpts. 52 SetRawTCPServerOpts(value rawtcpserver.Options) Options 53 54 // RawTCPServerOpts returns the RawTCPServerOpts. 55 RawTCPServerOpts() rawtcpserver.Options 56 57 // SetHTTPAddr sets the HTTP address. 58 SetHTTPAddr(value string) Options 59 60 // HTTPAddr returns the HTTP address. 61 HTTPAddr() string 62 63 // SetHTTPServerOpts sets the HTTPServerOpts. 64 SetHTTPServerOpts(value httpserver.Options) Options 65 66 // HTTPServerOpts returns the HTTPServerOpts. 67 HTTPServerOpts() httpserver.Options 68 69 // SetInstrumentOpts sets the InstrumentOpts. 70 SetInstrumentOpts(value instrument.Options) Options 71 72 // InstrumentOpts returns the InstrumentOpts. 73 InstrumentOpts() instrument.Options 74 75 // SetRWOptions sets RW options. 76 SetRWOptions(value xio.Options) Options 77 78 // RWOptions returns the RW options. 79 RWOptions() xio.Options 80 } 81 82 type options struct { 83 m3msgAddr string 84 m3msgServerOpts m3msgserver.Options 85 rawTCPAddr string 86 rawTCPServerOpts rawtcpserver.Options 87 httpAddr string 88 httpServerOpts httpserver.Options 89 iOpts instrument.Options 90 rwOpts xio.Options 91 } 92 93 // NewOptions creates a new aggregator server options. 94 func NewOptions(iOpts instrument.Options) Options { 95 return &options{ 96 iOpts: iOpts, 97 rwOpts: xio.NewOptions(), 98 } 99 } 100 101 func (o *options) SetM3MsgAddr(value string) Options { 102 opts := *o 103 opts.m3msgAddr = value 104 return &opts 105 } 106 107 func (o *options) M3MsgAddr() string { 108 return o.m3msgAddr 109 } 110 111 func (o *options) SetM3MsgServerOpts(value m3msgserver.Options) Options { 112 opts := *o 113 opts.m3msgServerOpts = value 114 return &opts 115 } 116 117 func (o *options) M3MsgServerOpts() m3msgserver.Options { 118 return o.m3msgServerOpts 119 } 120 121 func (o *options) SetRawTCPAddr(value string) Options { 122 opts := *o 123 opts.rawTCPAddr = value 124 return &opts 125 } 126 127 func (o *options) RawTCPAddr() string { 128 return o.rawTCPAddr 129 } 130 131 func (o *options) SetRawTCPServerOpts(value rawtcpserver.Options) Options { 132 opts := *o 133 opts.rawTCPServerOpts = value 134 return &opts 135 } 136 137 func (o *options) RawTCPServerOpts() rawtcpserver.Options { 138 return o.rawTCPServerOpts 139 } 140 141 func (o *options) SetHTTPAddr(value string) Options { 142 opts := *o 143 opts.httpAddr = value 144 return &opts 145 } 146 147 func (o *options) HTTPAddr() string { 148 return o.httpAddr 149 } 150 151 func (o *options) SetHTTPServerOpts(value httpserver.Options) Options { 152 opts := *o 153 opts.httpServerOpts = value 154 return &opts 155 } 156 157 func (o *options) HTTPServerOpts() httpserver.Options { 158 return o.httpServerOpts 159 } 160 161 func (o *options) SetInstrumentOpts(value instrument.Options) Options { 162 opts := *o 163 opts.iOpts = value 164 return &opts 165 } 166 167 func (o *options) InstrumentOpts() instrument.Options { 168 return o.iOpts 169 } 170 171 func (o *options) SetRWOptions(value xio.Options) Options { 172 opts := *o 173 opts.rwOpts = value 174 return &opts 175 } 176 177 func (o *options) RWOptions() xio.Options { 178 return o.rwOpts 179 }