Documentation ¶
Index ¶
- Constants
- Variables
- func Delete(obj Object) error
- func DeleteObjects(objs []Object) error
- func EnsureEtcd(etcdp **clientv3.Client) error
- func Error(message string) error
- func ErrorE(message string, err error) error
- func ErrorEF(message string, err error, fields log.Fields) error
- func ErrorF(message string, fields log.Fields) error
- func EtcdClient() (*clientv3.Client, error)
- func EtcdConnect() (*clientv3.Client, error)
- func FromJSON(o Object, b []byte)
- func GetIntLike(x interface{}) (int, error)
- func IsTxnFailed(err error) bool
- func RUC(o Object, update func(o Object)) error
- func Read(obj Object) error
- func ReadNew(obj Object) error
- func ReadObjects(objs []Object) (int, error)
- func ReadRevision(obj Object) (revision int64, err error)
- func ReadWait(obj Object, timer *ReadTimer) error
- func RunObjectTx(otx ObjectTx) error
- func RunObjectTxPrefix(puts []Object, deletePrefix string) error
- func SetEtcdConfig(cfg *ServiceConfig)
- func TbModel() *xir.Net
- func ToJSON(o Object) string
- func Touch(obj Object) error
- func TouchObjects(objs []Object) error
- func TxnFailed(message string) error
- func Warn(message string)
- func WarnE(message string, err error)
- func WarnEF(message string, err error, fields log.Fields)
- func WarnF(message string, fields log.Fields)
- func WithEtcd(f func(*clientv3.Client) error) error
- func WithMinEtcd(f func(*clientv3.Client) (interface{}, error)) (interface{}, error)
- func Write(obj Object, opts ...etcd.OpOption) error
- func WriteObjects(objs []Object, fresh bool, opts ...etcd.OpOption) error
- type CountSet
- type Object
- type ObjectTx
- type ReadTimer
- type ServiceConfig
- type TLSConfig
Constants ¶
const (
// TxnFailedPrefix is the prefix message for all transaction failure errors.
TxnFailedPrefix = "txn failed"
)
Variables ¶
var ErrNotFound = fmt.Errorf("not found")
ErrNotFound means an object was not found.
var Version = "undefined"
Version contains the cogs version string
Functions ¶
func DeleteObjects ¶
DeleteObjects deletes a set of objects from the datastore.
func EnsureEtcd ¶
EnsureEtcd Make sure we always have an etcd connection
func ErrorE ¶
ErrorE encapsulates err in a structured log and return an abstracted high-level error with message as the payload
func ErrorEF ¶
ErrorEF encapsulates fields and err in a structured log and return an abstracted high-level error with message as the payload
func ErrorF ¶
ErrorF encapsulates fields in a structured log and return an abstracted high-level error with message as the payload
func EtcdClient ¶
EtcdClient read the specific configuration files to initiate etcd connection
func EtcdConnect ¶
EtcdConnect Try to get a etcd client- assumption EtcdClient is async until used
func FromJSON ¶
FromJSON reads reads on object from byte array encoded json. If the object is a protobuf, then protobuf is used instead.
func GetIntLike ¶
GetIntLike is needed for data that gets cross-serialized and the number format is uncertain. This function works for both float64 and int underlying data types.
func IsTxnFailed ¶
IsTxnFailed detects if an error is a transaction failure error.
func RUC ¶
RUC performs a read-update-commit on the provided object using the specified update function.
func ReadNew ¶
ReadNew reads an object form the datastore, and does not throw an error if the object is not found.
func ReadObjects ¶
ReadObjects reads a set of objects from the datastore in a one-shot transaction.
func ReadRevision ¶
ReadRevision reads an object, and returns the etcd key revision for that object
func ReadWait ¶
ReadWait attempts to read an object repeatedly until a timeout threshold is reached defined by timer. If timer is nil the defaults of 30 seconds with a retry period of 250 milliseconds is applied
func RunObjectTxPrefix ¶
RunObjectTxPrefix a bastaradization of RunObjectTx, making it so put is still object array, but delete is a prefix for the txn
func SetEtcdConfig ¶
func SetEtcdConfig(cfg *ServiceConfig)
SetEtcdConfig sets the global etcd configuration settings
func ToJSON ¶
ToJSON marshals an object to JSON form. If the object is a protobuf, protobuf is used instead.
func WithEtcd ¶
WithEtcd executes a function against an etcd client with a managed connection lifetime.
func WithMinEtcd ¶
WithMinEtcd executes a function against an etcd client with a managed connection lifetime.
Types ¶
type CountSet ¶
type CountSet struct { Name string `json:"name"` Size int `json:"size,omitempty"` Values []int `json:"values"` Offset int `json:"offset"` // contains filtered or unexported fields }
A CountSet is a dense counter. When the counter is incremented the lowest unused index is returned. When an index is deleted, it's available for use again.
func (*CountSet) GetVersion ¶
GetVersion returns the current datastore version of the object
func (*CountSet) SetVersion ¶
SetVersion sets the current datastore version of the object
type ServiceConfig ¶
ServiceConfig encapsulates information for communicating with services.
func (*ServiceConfig) Endpoint ¶
func (s *ServiceConfig) Endpoint() string
Endpoint returns the endpoint string of a service config.