github.com/m3db/m3@v1.5.0/src/cluster/integration/etcd/types.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  	"io"
    25  	"time"
    26  
    27  	"github.com/m3db/m3/src/cluster/client"
    28  	etcdclient "github.com/m3db/m3/src/cluster/client/etcd"
    29  	"github.com/m3db/m3/src/x/instrument"
    30  )
    31  
    32  // EmbeddedKV is an embedded etcd server wrapped around
    33  // by m3cluster utilities.
    34  type EmbeddedKV interface {
    35  	io.Closer
    36  
    37  	// Start starts the embedded KV.
    38  	Start() error
    39  
    40  	// Endpoints returns the active endpoints for the embedded KV.
    41  	Endpoints() []string
    42  
    43  	// ConfigServiceClient returns a m3cluster wrapper
    44  	// around the embedded KV.
    45  	ConfigServiceClient(fns ...ClientOptFn) (client.Client, error)
    46  }
    47  
    48  // ClientOptFn updates etcdclient.Option with any custom configs.
    49  type ClientOptFn func(etcdclient.Options) etcdclient.Options
    50  
    51  // Options specify the knobs to control the embedded KV.
    52  type Options interface {
    53  	// SetInstrumentOptions sets the instrumentation options.
    54  	SetInstrumentOptions(value instrument.Options) Options
    55  
    56  	// InstrumentOptions returns the instrumentation options.
    57  	InstrumentOptions() instrument.Options
    58  
    59  	// SetDir sets the working directory.
    60  	SetDir(value string) Options
    61  
    62  	// Dir returns the working directory.
    63  	Dir() string
    64  
    65  	// SetInitTimeout sets the init timeout.
    66  	SetInitTimeout(value time.Duration) Options
    67  
    68  	// InitTimeout returns the init timeout.
    69  	InitTimeout() time.Duration
    70  
    71  	// SetServiceID sets the service id for KV operations.
    72  	SetServiceID(value string) Options
    73  
    74  	// ServiceID returns the service id for KV operations.
    75  	ServiceID() string
    76  
    77  	// SetEnvironment sets the environment for KV operations.
    78  	SetEnvironment(value string) Options
    79  
    80  	// Environment returns the environment for KV operations.
    81  	Environment() string
    82  
    83  	// SetZone sets the zone for KV operations.
    84  	SetZone(value string) Options
    85  
    86  	// Zone returns the zone for KV operations.
    87  	Zone() string
    88  }