From 935bbebcd0aedfef11ecb564851aacf6a97ffb36 Mon Sep 17 00:00:00 2001 From: Michael Gasch <mgasch@amazon.de> Date: Mon, 4 Sep 2023 16:35:30 +0200 Subject: [PATCH] docs: update readme --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 50e3406..e121698 100644 --- a/README.md +++ b/README.md @@ -59,9 +59,15 @@ a SOAP-based events API into an HTTP/REST streaming API. # Usage -The API is intentionally kept minimal. A new `Log` is constructed with -`memlog.New(ctx, options...)`. Data as `[]byte` is written to the log with -`Log.Write(ctx, data)`. +```go + ml, _ := memlog.New(ctx) // create log + offset, _ := ml.Write(ctx, []byte("Hello World")) // write some data + record, _ := ml.Read(ctx, offset) // read back data + fmt.Printf(string(record.Data)) // prints "Hello World" +``` + +The `memlog` API is intentionally kept minimal. A new `Log` is constructed with `memlog.New(ctx, options...)`. Data as +`[]byte` is written to the log with `Log.Write(ctx, data)`. The first write to the `Log` using *default* `Options` starts at position (`Offset`) `0`. Every write creates an immutable `Record` in the `Log`. @@ -89,7 +95,7 @@ creating multiple `Logs` might be useful. For example: 💡 For use cases where you want to order the log by `key(s)`, consider using the specialised [`sharded.Log`](sharded/README.md). -## Example +## Full Example ```go package main