コード例 #1
0
ファイル: example_test.go プロジェクト: leevlad/dynatools
func Example() {
	client := dynago.NewClient(executor)

	// Create the person we want in the database.
	person := Person{Id: 5, Name: "Bob", Age: 40, Address: "123 fake street"}
	client.PutItem("Person", person.AsDocument()).Execute()

	// Bob's address was fake, let's blank it out:
	person.Address = ""
	update := safeupdate.Build(personKeys, person.AsDocument())

	// output: SET Age=:a, #b=:b REMOVE Address
	fmt.Println(update.Expression)

	// Okay, we proved our point, let's execute it:
	update.Apply(client, "Person").Execute()
}
コード例 #2
0
ファイル: example_test.go プロジェクト: leevlad/dynatools
func Example() {
	client := dynago.NewClient(executor)
	writer := bulk.New(bulk.Config{
		Client: client,
		Table:  "people",
	})

	// Start a goroutine to read results
	go resultReader(writer.Results())

	// Start putting 1000 records of bulk data
	for i := 0; i < 1000; i++ {
		writer.Write(dynago.Document{
			"Id":   i,
			"Name": fmt.Sprintf("User%d", i),
		})
	}

	writer.CloseWait()
}
コード例 #3
0
ファイル: example_test.go プロジェクト: leevlad/dynatools
func ExampleStreamer() {
	client := dynago.NewClient(executor)
	result, err := client.DescribeTable("mytable")
	if err != nil {
		return
	}

	config := streams.NewConfig().
		WithExecutor(executor).
		WithArn(result.Table.LatestStreamArn)
	streamer := streams.NewStreamer(config)

	// This is actually the mainloop of the application. It waits for newly
	// discovered shards to investigate, and the channel will close if the
	// streamer is ever shut down.
	for shard := range streamer.ShardUpdater() {
		log.Printf("Got shard with ID %s", shard.Id())
		go worker(shard)
	}
	log.Printf("Streamer exiting.")
	streamer.Close()
}