Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Client ¶
func Client(s bandmaster.Service) *gocql.Session
Client returns the underlying `gocql.Session` of the given service.
It assumes that the service is ready; i.e. it might return nil if it's actually not.
NOTE: This will panic if `s` is not a `cql.Service`.
func Config ¶
func Config(s bandmaster.Service) *gocql.ClusterConfig
Config returns the underlying `gocql.ClusterConfig` of the given service.
NOTE: This will panic if `s` is not a `cql.Service`.
func New ¶
func New(cc *gocql.ClusterConfig) bandmaster.Service
New creates a new CQL service using the provided `gocql.ClusterConfig`. You may use the helpers for environment-based configuration to get a pre-configured `gocql.ClusterConfig` with sane defaults.
It doesn't open any connection nor does it do any kind of I/O; i.e. it cannot fail.
Types ¶
type Consistency ¶
type Consistency gocql.Consistency
Consistency is used to configure CQL's consistency value via the environment.
func (*Consistency) Decode ¶
func (gcd *Consistency) Decode(c string) error
func (Consistency) String ¶
func (gcd Consistency) String() string
type Env ¶
type Env struct { Addrs []string `envconfig:"ADDRS" default:"localhost:9042"` ProtocolVersion int `envconfig:"PROTOCOL_VERSION" default:"2"` TimeoutConnect time.Duration `envconfig:"TIMEOUT_CONNECT" default:"30s"` TimeoutLimit int64 `envconfig:"TIMEOUT_LIMIT" default:"10"` Timeout time.Duration `envconfig:"TIMEOUT" default:"30s"` NbConns int `envconfig:"NB_CONNS" default:"8"` Consistency Consistency `envconfig:"CONSISTENCY" default:"LOCAL_QUORUM"` HostFilter string `envconfig:"HOST_FILTER" default:""` }
Env can be used to configure a CQL session via the environment.
It comes with sane defaults for a local development set-up.
func NewEnv ¶
NewEnv parses the environment and returns a new `Env` structure.
`prefix` defines the prefix for the environment keys, e.g. with a 'XX' prefix, 'REPLICAS' would become 'XX_REPLICAS'.
func (*Env) Config ¶
func (e *Env) Config() *gocql.ClusterConfig
Config returns a `gocql.ClusterConfig` using the values from the environment.
type Service ¶
type Service struct { *bandmaster.ServiceBase // "inheritance" // contains filtered or unexported fields }
Service implements a CQL service based on the 'gocql/gocql' package.
func (*Service) Start ¶
Start opens a connection and requests the version of the server: if everything goes smoothly, the service is marked as 'started'; otherwise, an error is returned.
The given context defines the deadline for the above-mentionned operations.
Start is used by BandMaster's internal machinery, it shouldn't ever be called directly by the end-user of the service.