Created
June 24, 2013 12:47
-
-
Save davegardnerisme/5849800 to your computer and use it in GitHub Desktop.
Gossie test 2, with mapping.
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( | |
| "github.com/carloscm/gossie/src/gossie" | |
| ) | |
| /* | |
| CREATE TABLE test2 ( | |
| id varchar, | |
| service_name varchar, | |
| service_version bigint, | |
| machine_class varchar, | |
| PRIMARY KEY (id) | |
| ); | |
| */ | |
| type ProvisionedService struct { | |
| Id string `cf:"test2" key:"Id"` | |
| ServiceName string | |
| ServiceVersion int64 | |
| MachineClass string | |
| } | |
| func main() { | |
| pool, err := gossie.NewConnectionPool([]string{"localhost:19160"}, "test", gossie.PoolOptions{Size: 50, Timeout: 3000}) | |
| if err != nil { | |
| panic(err) | |
| } | |
| mapping, err := gossie.NewMapping(&ProvisionedService{}) | |
| if err != nil { | |
| panic(err) | |
| } | |
| row, err := mapping.Map(&ProvisionedService{"theID", "discovery-service", 20130601131111, "A"}) | |
| if err != nil { | |
| panic(err) | |
| } | |
| err = pool.Writer().Insert("test2", row).Run() | |
| if err != nil { | |
| panic(err) | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment