Created
February 1, 2013 10:27
-
-
Save davegardnerisme/4690524 to your computer and use it in GitHub Desktop.
Updated Gossie test - this time with error checking on connection pool creation (this now works as expected)
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, err := gossie.NewConnectionPool([]string{"cassandra.devel:9160"}, "trace", gossie.PoolOptions{Size: 50, Timeout: 3000}) | |
| if err != nil { | |
| log.Fatal("Error establishing connection pool", err) | |
| } | |
| 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