From d741b81ab5634483d3abc45615cd10b1befc99bc Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Wed, 26 Oct 2016 22:11:43 -0700 Subject: [PATCH] Add better docs for Group --- group.go | 24 ++++++++++++++++++++++-- group_test.go | 4 ++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/group.go b/group.go index 84aa8a228..04403bb74 100644 --- a/group.go +++ b/group.go @@ -19,8 +19,28 @@ You can open a Group to keep restrictions on an AutoFile, like the maximum size of each chunk, and/or the total amount of bytes stored in the group. -The Group can also be used to binary-search, and to read atomically -with respect to the Group's Head (the AutoFile being appended to) +The first file to be written in the Group.Dir is the head file. + + Dir/ + - + +Once the Head file reaches the size limit, it will be rotated. + + Dir/ + - .000 // First rolled file + - // New head path, starts empty. + // The implicit index is 001. + +As more files are written, the index numbers grow... + + Dir/ + - .000 // First rolled file + - .001 // Second rolled file + - ... + - // New head path + +The Group can also be used to binary-search for some line, +assuming that marker lines are written occasionally. */ const groupCheckDuration = 1000 * time.Millisecond diff --git a/group_test.go b/group_test.go index ced88c8bb..f7c70b709 100644 --- a/group_test.go +++ b/group_test.go @@ -230,6 +230,10 @@ func TestSearch(t *testing.T) { if !strings.HasPrefix(line, "INFO 0 ") { t.Error("Failed to fetch correct line, which is the earliest INFO") } + err = gr.Close() + if err != nil { + t.Error("Failed to close GroupReader", err) + } } // Now search for something that is too large.