예제 #1
0
func ExampleStream_Pull_1() {
	stream, _ := stream.New("Users", config)
	user := User{"damian"}

	stream.Clean()

	stream.Push(user)
	stream.Push(user)
	stream.Push(user)
	stream.Push(user)

	for {
		_, err := stream.Pull()
		if err != nil {
			fmt.Printf("ERR: %s\n", err)
			break
		}
	}

	// Output:
	// ERR: redigo: nil returned
}
예제 #2
0
func ExampleStream_Pull() {
	stream, _ := stream.New("Users", config)
	user := User{"damian"}

	stream.Clean()
	stream.Push(user)
	stream.Push(user)

	for i := 1; i <= 2; i++ {
		if _, err := stream.Pull(); err != nil {
			fmt.Printf("%s\n")
		}

		fmt.Printf("ok\n")
	}

	fmt.Printf("Size: %d", stream.Size())

	// Output:
	//
	// ok
	// ok
	// Size: 0
}
예제 #3
0
func ExampleStream_Push() {
	stream, err := stream.New("test", config)
	if err != nil {
		fmt.Printf("ERROR: %s\n", err)
		return
	}

	stream.Clean()

	err = stream.Push(item)
	if err != nil {
		fmt.Printf("ERROR: %s\n", err)
		return
	}

	fmt.Printf("%d", stream.Size())

	// Output:
	// 1
}