func Benchmark_Queuefka_Write(b *testing.B) { wt, _ := queuefka.NewWriter(topic, segmentSizeHint) for i := 0; i < b.N; i++ { wt.Write(value) } wt.Close() }
func Test_Queuefka(t *testing.T) { wt, err := queuefka.NewWriter(topic, segmentSizeHint) if err != nil { panic(err) } defer wt.Close() rd, err := queuefka.NewReader(topic, 0x0000) if err != nil && err != queuefka.ErrEndOfLog { panic(err) } defer rd.Close() wt.Write(value) wt.Flush() raw, err := rd.Read() if err != nil && err != queuefka.ErrEndOfLog { panic(err) } msg := string(raw) if msg != string(value) { println(msg) panic("queuefka: Read does not match write:") } wt.Status() }
func main() { wt, _ := queuefka.NewWriter("./mytopic", 1024*1024) defer wt.Close() wt.Write([]byte(string("こんにちは世界!"))) // Hello World in Japanese (i hope) wt.Flush() rd, _ := queuefka.NewReader("./mytopic", 0x0000) defer rd.Close() msg, _ := rd.Read() println(string(msg)) }
func Test_Queuefka_Sequential(t *testing.T) { wt, err := queuefka.NewWriter(topic, segmentSizeHint) if err != nil { panic(err) } defer wt.Close() rd, err := queuefka.NewReader(topic, 0x0000) if err != nil && err != queuefka.ErrEndOfLog { panic(err) } defer rd.Close() for i := 0; i < 50000; i++ { wt.Write(value) wt.Flush() raw, err := rd.Read() if err != nil { if err == queuefka.ErrEndOfLog { break } panic(err) } msg := string(raw) if msg != string(value) { println(msg) panic("queuefka: Read does not match write:") } // this extra read should return ErrEndOfLog raw, err = rd.Read() if err != nil { if err != queuefka.ErrEndOfLog { panic(err) } continue } } wt.Status() }