gocql: tux21b.org/v1/gocql Index | Files

package gocql

import "tux21b.org/v1/gocql"

Package gocql implements a fast and robust Cassandra driver for the Go programming language.

Copyright (c) 2012 The gocql Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. This file will be the future home for more policies

The uuid package can be used to generate and parse universally unique identifiers, a standardized format in the form of a 128 bit number.

http://tools.ietf.org/html/rfc4122

Index

Package Files

cluster.go compressor.go conn.go connectionpool.go doc.go errors.go frame.go helpers.go host_source.go marshal.go policies.go session.go topology.go uuid.go

Constants

const (
    VariantNCSCompat = 0
    VariantIETF      = 2
    VariantMicrosoft = 6
    VariantFuture    = 7
)
const BatchSizeMaximum = 65535

BatchSizeMaximum is the maximum number of statements a batch operation can have. This limit is set by cassandra and could change in the future.

Variables

var (
    ErrNoHosts              = errors.New("no hosts provided")
    ErrNoConnectionsStarted = errors.New("no connections were made when creating the session")
    ErrHostQueryFailed      = errors.New("unable to populate Hosts")
)
var (
    ErrNotFound      = errors.New("not found")
    ErrUnavailable   = errors.New("unavailable")
    ErrUnsupported   = errors.New("feature not supported")
    ErrTooManyStmts  = errors.New("too many statements")
    ErrUseStmt       = errors.New("use statements aren't supported. Please see https://github.com/gocql/gocql for explaination.")
    ErrSessionClosed = errors.New("session has been closed")
    ErrNoConnections = errors.New("no connections available")
)
var ConsistencyNames = []string{
    0:           "default",
    Any:         "any",
    One:         "one",
    Two:         "two",
    Three:       "three",
    Quorum:      "quorum",
    All:         "all",
    LocalQuorum: "localquorum",
    EachQuorum:  "eachquorum",
    Serial:      "serial",
    LocalSerial: "localserial",
    LocalOne:    "localone",
}
var (
    ErrQueryArgLength = errors.New("query argument length mismatch")
)

func Marshal Uses

func Marshal(info *TypeInfo, value interface{}) ([]byte, error)

Marshal returns the CQL encoding of the value for the Cassandra internal type described by the info parameter.

func NewErrProtocol Uses

func NewErrProtocol(format string, args ...interface{}) error

func Unmarshal Uses

func Unmarshal(info *TypeInfo, data []byte, value interface{}) error

Unmarshal parses the CQL encoded data based on the info parameter that describes the Cassandra internal data type and stores the result in the value pointed by value.

type Authenticator Uses

type Authenticator interface {
    Challenge(req []byte) (resp []byte, auth Authenticator, err error)
    Success(data []byte) error
}

type Batch Uses

type Batch struct {
    Type    BatchType
    Entries []BatchEntry
    Cons    Consistency
    // contains filtered or unexported fields
}

func NewBatch Uses

func NewBatch(typ BatchType) *Batch

NewBatch creates a new batch operation without defaults from the cluster

func (*Batch) Attempts Uses

func (b *Batch) Attempts() int

Attempts returns the number of attempts made to execute the batch.

func (*Batch) Bind Uses

func (b *Batch) Bind(stmt string, bind func(q *QueryInfo) ([]interface{}, error))

Bind adds the query to the batch operation and correlates it with a binding callback that will be invoked when the batch is executed. The binding callback allows the application to define which query argument values will be marshalled as part of the batch execution.

func (*Batch) Latency Uses

func (b *Batch) Latency() int64

Latency returns the average number of nanoseconds to execute a single attempt of the batch.

func (*Batch) Query Uses

func (b *Batch) Query(stmt string, args ...interface{})

Query adds the query to the batch operation

func (*Batch) RetryPolicy Uses

func (b *Batch) RetryPolicy(r RetryPolicy) *Batch

RetryPolicy sets the retry policy to use when executing the batch operation

func (*Batch) Size Uses

func (b *Batch) Size() int

Size returns the number of batch statements to be executed by the batch operation.

type BatchEntry Uses

type BatchEntry struct {
    Stmt string
    Args []interface{}
    // contains filtered or unexported fields
}

type BatchType Uses

type BatchType int
const (
    LoggedBatch   BatchType = 0
    UnloggedBatch BatchType = 1
    CounterBatch  BatchType = 2
)

type ClusterConfig Uses

type ClusterConfig struct {
    Hosts            []string      // addresses for the initial connections
    CQLVersion       string        // CQL version (default: 3.0.0)
    ProtoVersion     int           // version of the native protocol (default: 2)
    Timeout          time.Duration // connection timeout (default: 600ms)
    Port             int           // port (default: 9042)
    Keyspace         string        // initial keyspace (optional)
    NumConns         int           // number of connections per host (default: 2)
    NumStreams       int           // number of streams per connection (default: 128)
    Consistency      Consistency   // default consistency level (default: Quorum)
    Compressor       Compressor    // compression algorithm (default: nil)
    Authenticator    Authenticator // authenticator (default: nil)
    RetryPolicy      RetryPolicy   // Default retry policy to use for queries (default: 0)
    SocketKeepalive  time.Duration // The keepalive period to use, enabled if > 0 (default: 0)
    ConnPoolType     NewPoolFunc   // The function used to create the connection pool for the session (default: NewSimplePool)
    DiscoverHosts    bool          // If set, gocql will attempt to automatically discover other members of the Cassandra cluster (default: false)
    MaxPreparedStmts int           // Sets the maximum cache size for prepared statements globally for gocql (default: 1000)
    Discovery        DiscoveryConfig
}

ClusterConfig is a struct to configure the default cluster implementation of gocoql. It has a varity of attributes that can be used to modify the behavior to fit the most common use cases. Applications that requre a different setup must implement their own cluster.

func NewCluster Uses

func NewCluster(hosts ...string) *ClusterConfig

NewCluster generates a new config for the default cluster implementation.

func (*ClusterConfig) CreateSession Uses

func (cfg *ClusterConfig) CreateSession() (*Session, error)

CreateSession initializes the cluster based on this config and returns a session object that can be used to interact with the database.

type ColumnInfo Uses

type ColumnInfo struct {
    Keyspace string
    Table    string
    Name     string
    TypeInfo *TypeInfo
}

type Compressor Uses

type Compressor interface {
    Name() string
    Encode(data []byte) ([]byte, error)
    Decode(data []byte) ([]byte, error)
}

type Conn Uses

type Conn struct {
    // contains filtered or unexported fields
}

Conn is a single connection to a Cassandra node. It can be used to execute queries, but users are usually advised to use a more reliable, higher level API.

func Connect Uses

func Connect(addr string, cfg ConnConfig, pool ConnectionPool) (*Conn, error)

Connect establishes a connection to a Cassandra node. You must also call the Serve method before you can execute any queries.

func (*Conn) Address Uses

func (c *Conn) Address() string

func (*Conn) Close Uses

func (c *Conn) Close()

func (*Conn) Closed Uses

func (c *Conn) Closed() bool

func (*Conn) Pick Uses

func (c *Conn) Pick(qry *Query) *Conn

func (*Conn) UseKeyspace Uses

func (c *Conn) UseKeyspace(keyspace string) error

type ConnConfig Uses

type ConnConfig struct {
    ProtoVersion  int
    CQLVersion    string
    Timeout       time.Duration
    NumStreams    int
    Compressor    Compressor
    Authenticator Authenticator
    Keepalive     time.Duration
}

type ConnectionPool Uses

type ConnectionPool interface {
    Pick(*Query) *Conn
    Size() int
    HandleError(*Conn, error, bool)
    Close()
    SetHosts(host []HostInfo)
}

ConnectionPool represents the interface gocql will use to work with a collection of connections.

Purpose

The connection pool in gocql opens and closes connections as well as selects an available connection for gocql to execute a query against. The pool is also respnsible for handling connection errors that are caught by the connection experiencing the error.

A connection pool should make a copy of the variables used from the ClusterConfig provided to the pool upon creation. ClusterConfig is a pointer and can be modified after the creation of the pool. This can lead to issues with variables being modified outside the expectations of the ConnectionPool type.

Example of Single Connection Pool:

type SingleConnection struct {
	conn *Conn
	cfg *ClusterConfig
}

func NewSingleConnection(cfg *ClusterConfig) ConnectionPool {
	addr := strings.TrimSpace(cfg.Hosts[0])
	if strings.Index(addr, ":") < 0 {
		addr = fmt.Sprintf("%s:%d", addr, cfg.Port)
	}
	connCfg := ConnConfig{
		ProtoVersion:  cfg.ProtoVersion,
		CQLVersion:    cfg.CQLVersion,
		Timeout:       cfg.Timeout,
		NumStreams:    cfg.NumStreams,
		Compressor:    cfg.Compressor,
		Authenticator: cfg.Authenticator,
		Keepalive:     cfg.SocketKeepalive,
	}
	pool := SingleConnection{cfg:cfg}
	pool.conn = Connect(addr,connCfg,pool)
	return &pool
}

func (s *SingleConnection) HandleError(conn *Conn, err error, closed bool) {
	if closed {
		connCfg := ConnConfig{
			ProtoVersion:  cfg.ProtoVersion,
			CQLVersion:    cfg.CQLVersion,
			Timeout:       cfg.Timeout,
			NumStreams:    cfg.NumStreams,
			Compressor:    cfg.Compressor,
			Authenticator: cfg.Authenticator,
			Keepalive:     cfg.SocketKeepalive,
		}
		s.conn = Connect(conn.Address(),connCfg,s)
	}
}

func (s *SingleConnection) Pick(qry *Query) *Conn {
	if s.conn.isClosed {
		return nil
	}
	return s.conn
}

func (s *SingleConnection) Size() int {
	return 1
}

func (s *SingleConnection) Close() {
	s.conn.Close()
}

This is a very simple example of a type that exposes the connection pool interface. To assign this type as the connection pool to use you would assign it to the ClusterConfig like so:

cluster := NewCluster("127.0.0.1")
cluster.ConnPoolType = NewSingleConnection
...
session, err := cluster.CreateSession()

To see a more complete example of a ConnectionPool implementation please see the SimplePool type.

func NewSimplePool Uses

func NewSimplePool(cfg *ClusterConfig) ConnectionPool

NewSimplePool is the function used by gocql to create the simple connection pool. This is the default if no other pool type is specified.

type Consistency Uses

type Consistency int
const (
    Any Consistency = 1 + iota
    One
    Two
    Three
    Quorum
    All
    LocalQuorum
    EachQuorum
    Serial
    LocalSerial
    LocalOne
)

func (Consistency) String Uses

func (c Consistency) String() string

type DiscoveryConfig Uses

type DiscoveryConfig struct {
    // If not empty will filter all discoverred hosts to a single Data Centre (default: "")
    DcFilter string
    // If not empty will filter all discoverred hosts to a single Rack (default: "")
    RackFilter string
    // The interval to check for new hosts (default: 30s)
    Sleep time.Duration
}

To enable periodic node discovery enable DiscoverHosts in ClusterConfig

type ErrProtocol Uses

type ErrProtocol struct {
    // contains filtered or unexported fields
}

type Error Uses

type Error struct {
    Code    int
    Message string
}

func (Error) Error Uses

func (e Error) Error() string

type HostInfo Uses

type HostInfo struct {
    Peer       string
    DataCenter string
    Rack       string
    HostId     string
    Tokens     []string
}

type Iter Uses

type Iter struct {
    // contains filtered or unexported fields
}

Iter represents an iterator that can be used to iterate over all rows that were returned by a query. The iterator might send additional queries to the database during the iteration if paging was enabled.

func (*Iter) Close Uses

func (iter *Iter) Close() error

Close closes the iterator and returns any errors that happened during the query or the iteration.

func (*Iter) Columns Uses

func (iter *Iter) Columns() []ColumnInfo

Columns returns the name and type of the selected columns.

func (*Iter) MapScan Uses

func (iter *Iter) MapScan(m map[string]interface{}) bool

MapScan takes a map[string]interface{} and populates it with a row That is returned from cassandra.

func (*Iter) RowData Uses

func (iter *Iter) RowData() (RowData, error)

func (*Iter) Scan Uses

func (iter *Iter) Scan(dest ...interface{}) bool

Scan consumes the next row of the iterator and copies the columns of the current row into the values pointed at by dest. Use nil as a dest value to skip the corresponding column. Scan might send additional queries to the database to retrieve the next set of rows if paging was enabled.

Scan returns true if the row was successfully unmarshaled or false if the end of the result set was reached or if an error occurred. Close should be called afterwards to retrieve any potential errors.

func (*Iter) SliceMap Uses

func (iter *Iter) SliceMap() ([]map[string]interface{}, error)

SliceMap is a helper function to make the API easier to use returns the data from the query in the form of []map[string]interface{}

type MarshalError Uses

type MarshalError string

func (MarshalError) Error Uses

func (m MarshalError) Error() string

type Marshaler Uses

type Marshaler interface {
    MarshalCQL(info *TypeInfo) ([]byte, error)
}

Marshaler is the interface implemented by objects that can marshal themselves into values understood by Cassandra.

type NewPoolFunc Uses

type NewPoolFunc func(*ClusterConfig) ConnectionPool

NewPoolFunc is the type used by ClusterConfig to create a pool of a specific type.

type Node Uses

type Node interface {
    Pick(qry *Query) *Conn
    Close()
}

type PasswordAuthenticator Uses

type PasswordAuthenticator struct {
    Username string
    Password string
}

func (PasswordAuthenticator) Challenge Uses

func (p PasswordAuthenticator) Challenge(req []byte) ([]byte, Authenticator, error)

func (PasswordAuthenticator) Success Uses

func (p PasswordAuthenticator) Success(data []byte) error

type Query Uses

type Query struct {
    // contains filtered or unexported fields
}

Query represents a CQL statement that can be executed.

func (*Query) Attempts Uses

func (q *Query) Attempts() int

Attempts returns the number of times the query was executed.

func (*Query) Bind Uses

func (q *Query) Bind(v ...interface{}) *Query

Bind sets query arguments of query. This can also be used to rebind new query arguments to an existing query instance.

func (*Query) Consistency Uses

func (q *Query) Consistency(c Consistency) *Query

Consistency sets the consistency level for this query. If no consistency level have been set, the default consistency level of the cluster is used.

func (*Query) Exec Uses

func (q *Query) Exec() error

Exec executes the query without returning any rows.

func (*Query) Iter Uses

func (q *Query) Iter() *Iter

Iter executes the query and returns an iterator capable of iterating over all results.

func (*Query) Latency Uses

func (q *Query) Latency() int64

Latency returns the average amount of nanoseconds per attempt of the query.

func (*Query) PageSize Uses

func (q *Query) PageSize(n int) *Query

PageSize will tell the iterator to fetch the result in pages of size n. This is useful for iterating over large result sets, but setting the page size to low might decrease the performance. This feature is only available in Cassandra 2 and onwards.

func (*Query) Prefetch Uses

func (q *Query) Prefetch(p float64) *Query

SetPrefetch sets the default threshold for pre-fetching new pages. If there are only p*pageSize rows remaining, the next page will be requested automatically.

func (*Query) RetryPolicy Uses

func (q *Query) RetryPolicy(r RetryPolicy) *Query

RetryPolicy sets the policy to use when retrying the query.

func (*Query) Scan Uses

func (q *Query) Scan(dest ...interface{}) error

Scan executes the query, copies the columns of the first selected row into the values pointed at by dest and discards the rest. If no rows were selected, ErrNotFound is returned.

func (*Query) ScanCAS Uses

func (q *Query) ScanCAS(dest ...interface{}) (applied bool, err error)

ScanCAS executes a lightweight transaction (i.e. an UPDATE or INSERT statement containing an IF clause). If the transaction fails because the existing values did not match, the previos values will be stored in dest.

func (*Query) Trace Uses

func (q *Query) Trace(trace Tracer) *Query

Trace enables tracing of this query. Look at the documentation of the Tracer interface to learn more about tracing.

type QueryInfo Uses

type QueryInfo struct {
    Id   []byte
    Args []ColumnInfo
    Rval []ColumnInfo
}

QueryInfo represents the meta data associated with a prepared CQL statement.

type RequestErrAlreadyExists Uses

type RequestErrAlreadyExists struct {
    Keyspace string
    Table    string
    // contains filtered or unexported fields
}

func (RequestErrAlreadyExists) Code Uses

func (e RequestErrAlreadyExists) Code() int

func (RequestErrAlreadyExists) Error Uses

func (e RequestErrAlreadyExists) Error() string

func (RequestErrAlreadyExists) Message Uses

func (e RequestErrAlreadyExists) Message() string

type RequestErrReadTimeout Uses

type RequestErrReadTimeout struct {
    Consistency Consistency
    Received    int
    BlockFor    int
    DataPresent byte
    // contains filtered or unexported fields
}

func (RequestErrReadTimeout) Code Uses

func (e RequestErrReadTimeout) Code() int

func (RequestErrReadTimeout) Error Uses

func (e RequestErrReadTimeout) Error() string

func (RequestErrReadTimeout) Message Uses

func (e RequestErrReadTimeout) Message() string

type RequestErrUnavailable Uses

type RequestErrUnavailable struct {
    Consistency Consistency
    Required    int
    Alive       int
    // contains filtered or unexported fields
}

func (RequestErrUnavailable) Code Uses

func (e RequestErrUnavailable) Code() int

func (RequestErrUnavailable) Error Uses

func (e RequestErrUnavailable) Error() string

func (RequestErrUnavailable) Message Uses

func (e RequestErrUnavailable) Message() string

type RequestErrUnprepared Uses

type RequestErrUnprepared struct {
    StatementId []byte
    // contains filtered or unexported fields
}

func (RequestErrUnprepared) Code Uses

func (e RequestErrUnprepared) Code() int

func (RequestErrUnprepared) Error Uses

func (e RequestErrUnprepared) Error() string

func (RequestErrUnprepared) Message Uses

func (e RequestErrUnprepared) Message() string

type RequestErrWriteTimeout Uses

type RequestErrWriteTimeout struct {
    Consistency Consistency
    Received    int
    BlockFor    int
    WriteType   string
    // contains filtered or unexported fields
}

func (RequestErrWriteTimeout) Code Uses

func (e RequestErrWriteTimeout) Code() int

func (RequestErrWriteTimeout) Error Uses

func (e RequestErrWriteTimeout) Error() string

func (RequestErrWriteTimeout) Message Uses

func (e RequestErrWriteTimeout) Message() string

type RequestError Uses

type RequestError interface {
    Code() int
    Message() string
    Error() string
}

type RetryPolicy Uses

type RetryPolicy struct {
    NumRetries int //Number of times to retry a query
}

RetryPolicy represents the retry behavour for a query.

type RoundRobin Uses

type RoundRobin struct {
    // contains filtered or unexported fields
}

func NewRoundRobin Uses

func NewRoundRobin() *RoundRobin

func (*RoundRobin) AddNode Uses

func (r *RoundRobin) AddNode(node Node)

func (*RoundRobin) Close Uses

func (r *RoundRobin) Close()

func (*RoundRobin) Pick Uses

func (r *RoundRobin) Pick(qry *Query) *Conn

func (*RoundRobin) RemoveNode Uses

func (r *RoundRobin) RemoveNode(node Node)

func (*RoundRobin) Size Uses

func (r *RoundRobin) Size() int

type RowData Uses

type RowData struct {
    Columns []string
    Values  []interface{}
}

type Session Uses

type Session struct {
    Pool ConnectionPool
    // contains filtered or unexported fields
}

Session is the interface used by users to interact with the database.

It's safe for concurrent use by multiple goroutines and a typical usage scenario is to have one global session object to interact with the whole Cassandra cluster.

This type extends the Node interface by adding a convinient query builder and automatically sets a default consinstency level on all operations that do not have a consistency level set.

func NewSession Uses

func NewSession(p ConnectionPool, c ClusterConfig) *Session

NewSession wraps an existing Node.

func (*Session) Bind Uses

func (s *Session) Bind(stmt string, b func(q *QueryInfo) ([]interface{}, error)) *Query

Bind generates a new query object based on the query statement passed in. The query is automatically prepared if it has not previously been executed. The binding callback allows the application to define which query argument values will be marshalled as part of the query execution. During execution, the meta data of the prepared query will be routed to the binding callback, which is responsible for producing the query argument values.

func (*Session) Close Uses

func (s *Session) Close()

Close closes all connections. The session is unusable after this operation.

func (*Session) Closed Uses

func (s *Session) Closed() bool

func (*Session) ExecuteBatch Uses

func (s *Session) ExecuteBatch(batch *Batch) error

ExecuteBatch executes a batch operation and returns nil if successful otherwise an error is returned describing the failure.

func (*Session) NewBatch Uses

func (s *Session) NewBatch(typ BatchType) *Batch

NewBatch creates a new batch operation using defaults defined in the cluster

func (*Session) Query Uses

func (s *Session) Query(stmt string, values ...interface{}) *Query

Query generates a new query object for interacting with the database. Further details of the query may be tweaked using the resulting query value before the query is executed. Query is automatically prepared if it has not previously been executed.

func (*Session) SetConsistency Uses

func (s *Session) SetConsistency(cons Consistency)

SetConsistency sets the default consistency level for this session. This setting can also be changed on a per-query basis and the default value is Quorum.

func (*Session) SetPageSize Uses

func (s *Session) SetPageSize(n int)

SetPageSize sets the default page size for this session. A value <= 0 will disable paging. This setting can also be changed on a per-query basis.

func (*Session) SetPrefetch Uses

func (s *Session) SetPrefetch(p float64)

SetPrefetch sets the default threshold for pre-fetching new pages. If there are only p*pageSize rows remaining, the next page will be requested automatically. This value can also be changed on a per-query basis and the default value is 0.25.

func (*Session) SetTrace Uses

func (s *Session) SetTrace(trace Tracer)

SetTrace sets the default tracer for this session. This setting can also be changed on a per-query basis.

type SimplePool Uses

type SimplePool struct {
    // contains filtered or unexported fields
}

SimplePool is the current implementation of the connection pool inside gocql. This pool is meant to be a simple default used by gocql so users can get up and running quickly.

func (*SimplePool) Close Uses

func (c *SimplePool) Close()

Close kills the pool and all associated connections.

func (*SimplePool) HandleError Uses

func (c *SimplePool) HandleError(conn *Conn, err error, closed bool)

HandleError is called by a Connection object to report to the pool an error has occured. Logic is then executed within the pool to clean up the erroroneous connection and try to top off the pool.

func (*SimplePool) Pick Uses

func (c *SimplePool) Pick(qry *Query) *Conn

Pick selects a connection to be used by the query.

func (*SimplePool) SetHosts Uses

func (c *SimplePool) SetHosts(hosts []HostInfo)

func (*SimplePool) Size Uses

func (p *SimplePool) Size() int

Size returns the number of connections currently active in the pool

type SnappyCompressor Uses

type SnappyCompressor struct{}

SnappyCompressor implements the Compressor interface and can be used to compress incoming and outgoing frames. The snappy compression algorithm aims for very high speeds and reasonable compression.

func (SnappyCompressor) Decode Uses

func (s SnappyCompressor) Decode(data []byte) ([]byte, error)

func (SnappyCompressor) Encode Uses

func (s SnappyCompressor) Encode(data []byte) ([]byte, error)

func (SnappyCompressor) Name Uses

func (s SnappyCompressor) Name() string

type Tracer Uses

type Tracer interface {
    Trace(traceId []byte)
}

Tracer is the interface implemented by query tracers. Tracers have the ability to obtain a detailed event log of all events that happened during the execution of a query from Cassandra. Gathering this information might be essential for debugging and optimizing queries, but this feature should not be used on production systems with very high load.

func NewTraceWriter Uses

func NewTraceWriter(session *Session, w io.Writer) Tracer

NewTraceWriter returns a simple Tracer implementation that outputs the event log in a textual format.

type Type Uses

type Type int

Type is the identifier of a Cassandra internal datatype.

const (
    TypeCustom    Type = 0x0000
    TypeAscii     Type = 0x0001
    TypeBigInt    Type = 0x0002
    TypeBlob      Type = 0x0003
    TypeBoolean   Type = 0x0004
    TypeCounter   Type = 0x0005
    TypeDecimal   Type = 0x0006
    TypeDouble    Type = 0x0007
    TypeFloat     Type = 0x0008
    TypeInt       Type = 0x0009
    TypeTimestamp Type = 0x000B
    TypeUUID      Type = 0x000C
    TypeVarchar   Type = 0x000D
    TypeVarint    Type = 0x000E
    TypeTimeUUID  Type = 0x000F
    TypeInet      Type = 0x0010
    TypeList      Type = 0x0020
    TypeMap       Type = 0x0021
    TypeSet       Type = 0x0022
)

func (Type) String Uses

func (t Type) String() string

String returns the name of the identifier.

type TypeInfo Uses

type TypeInfo struct {
    Type   Type
    Key    *TypeInfo // only used for TypeMap
    Elem   *TypeInfo // only used for TypeMap, TypeList and TypeSet
    Custom string    // only used for TypeCostum
}

TypeInfo describes a Cassandra specific data type.

func (*TypeInfo) New Uses

func (t *TypeInfo) New() interface{}

New creates a pointer to an empty version of whatever type is referenced by the TypeInfo receiver

func (TypeInfo) String Uses

func (t TypeInfo) String() string

String returns a human readable name for the Cassandra datatype described by t.

type UUID Uses

type UUID [16]byte

func ParseUUID Uses

func ParseUUID(input string) (UUID, error)

ParseUUID parses a 32 digit hexadecimal number (that might contain hypens) represanting an UUID.

func RandomUUID Uses

func RandomUUID() (UUID, error)

RandomUUID generates a totally random UUID (version 4) as described in RFC 4122.

func TimeUUID Uses

func TimeUUID() UUID

TimeUUID generates a new time based UUID (version 1) using the current time as the timestamp.

func UUIDFromBytes Uses

func UUIDFromBytes(input []byte) (UUID, error)

UUIDFromBytes converts a raw byte slice to an UUID.

func UUIDFromTime Uses

func UUIDFromTime(aTime time.Time) UUID

UUIDFromTime generates a new time based UUID (version 1) as described in RFC 4122. This UUID contains the MAC address of the node that generated the UUID, the given timestamp and a sequence number.

func (UUID) Bytes Uses

func (u UUID) Bytes() []byte

Bytes returns the raw byte slice for this UUID. A UUID is always 128 bits (16 bytes) long.

func (UUID) MarshalJSON Uses

func (u UUID) MarshalJSON() ([]byte, error)

Marshaling for JSON

func (UUID) Node Uses

func (u UUID) Node() []byte

Node extracts the MAC address of the node who generated this UUID. It will return nil if the UUID is not a time based UUID (version 1).

func (UUID) String Uses

func (u UUID) String() string

String returns the UUID in it's canonical form, a 32 digit hexadecimal number in the form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

func (UUID) Time Uses

func (u UUID) Time() time.Time

Time is like Timestamp, except that it returns a time.Time.

func (UUID) Timestamp Uses

func (u UUID) Timestamp() int64

Timestamp extracts the timestamp information from a time based UUID (version 1).

func (*UUID) UnmarshalJSON Uses

func (u *UUID) UnmarshalJSON(data []byte) error

Unmarshaling for JSON

func (UUID) Variant Uses

func (u UUID) Variant() int

Variant returns the variant of this UUID. This package will only generate UUIDs in the IETF variant.

func (UUID) Version Uses

func (u UUID) Version() int

Version extracts the version of this UUID variant. The RFC 4122 describes five kinds of UUIDs.

type UnmarshalError Uses

type UnmarshalError string

func (UnmarshalError) Error Uses

func (m UnmarshalError) Error() string

type Unmarshaler Uses

type Unmarshaler interface {
    UnmarshalCQL(info *TypeInfo, data []byte) error
}

Unmarshaler is the interface implemented by objects that can unmarshal a Cassandra specific description of themselves.

Package gocql imports 20 packages (graph) and is imported by 2 packages. Updated 2016-07-15. Refresh now. Tools for package owners.