Created
January 31, 2013 08:41
-
-
Save davegardnerisme/4681376 to your computer and use it in GitHub Desktop.
Playing with Gossie; trying to get a simple mutation working.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| gossie "github.com/carloscm/gossie/src/gossie" | |
| "log" | |
| ) | |
| func main() { | |
| pool, _ := gossie.NewConnectionPool([]string{"cassandra.devel:9160"}, "trace", gossie.PoolOptions{Size: 50, Timeout: 3000}) | |
| log.Println("Established C* pool...") | |
| // aim to mutate row: foo, column: var, value: baz | |
| columnName, err := gossie.Marshal("bar", gossie.BytesType) | |
| if err != nil { | |
| log.Println("Error marshaling column name", err) | |
| return | |
| } | |
| columnValue, err := gossie.Marshal("baz", gossie.BytesType) | |
| if err != nil { | |
| log.Println("Error marshaling column value", err) | |
| return | |
| } | |
| column := &gossie.Column{Name: columnName, Value: columnValue} | |
| rowKeyValue, err := gossie.Marshal("foo", gossie.BytesType) | |
| if err != nil { | |
| log.Println("Error marshaling row key", err) | |
| return | |
| } | |
| row := &gossie.Row{Key: rowKeyValue} | |
| row.Columns = append(row.Columns, column) | |
| // done marshaling | |
| log.Printf("%#v", row) | |
| pool.Writer().Insert("testcf", row).Run() | |
| log.Println("have written to C*") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment