Hello,

I would like to introduce you to my Go Cassandra client/library, Gossie:

https://github.com/carloscm/gossie

My intention was to use my favorite database with my favorite language,
with a library that allowed me to take advantage of idiomatic Go code with
the main strengths of Cassandra. I focused on offering a smooth as possible
integration with Go, including auto marshaling of most primitive built-in
types and structs. I also wanted to focus on what I think is the main
strength of the Cassandra data model, its column-oriented storage with
ordering, which I think it is unfortunately overlooked by many people just
wanting a typical key/value store. Features include:

- Connection pooling to N hosts, with transparent failover and retry of
queries
- A low level wrapper for the Thrift interface, much easier to use than the
bare Thrift bindings
- Extensive type marshaling, both automatic and custom, so you can force a
native integer to be serialised as a string for example
- Struct mapping into Cassandra rows (or row slices), with support for both
sparse and compact storage and field name/type overriding
- A high level query interface that deals with structs and mappings instead
of rows and column families

Here is an example, using a sparse storage column family with a slice (the
equivalent in the current README.md is a bit outdated):

/*
In CQL 3.0:
CREATE TABLE Timeline (
    UserID varchar,
    TweetID bigint,
    Author varchar,
    Body varchar,
    PRIMARY KEY (UserID, TweetID)
);
*/

// In Gossie:
type Tweet struct {
    UserID  string `cf:"Timeline" key:"UserID" cols:"TweetID"`
    TweetID int64
    Author  string
    Body    string
}

pool := gossie.NewConnectionPool([]string{"localhost:9160"}, "Example",
PoolOptions{Size: 50, Timeout: 3000})
query := pool.Query(NewMapping(&Tweet{}))

// all tweets for a given user between TweetID 1000 and 2000
result, err := query.Between(1000, 2000).Get("username")

// iterating over results
for {
    t := &Tweet{}
    err := result.Next(t)
    if err != nil {
        break
    }
}

Key and comparator component marshaling and positions are implicit and
automatic, based on the struct mapping, making it very easy to use complex
comparators. Also the sparse row support is flexible, in the sense it
doesn't depend on a fixed number fields. It is able to detect a new object
in the row by discontinuities in the composite values.

Feedback is welcome! Thank you!

Reply via email to