]> git.giacomolli.uk - onechat/blobdiff - probe.go
Separate multiline Go statements
[onechat] / probe.go
index 384d0f8357787e15fe5c5ccf07b9aa51bb0c20c5..a1ee38d17d6e43ff94c994e0c3a8f61d3b86f627 100644 (file)
--- a/probe.go
+++ b/probe.go
@@ -23,6 +23,28 @@ const (
        probeCallLimit = 660
 )
 
        probeCallLimit = 660
 )
 
+// ProbeSlotSummarizer lets at most cap(slots) builds call inner at once. A
+// build past the limit waits for a slot.
+type ProbeSlotSummarizer struct {
+       inner Summarizer
+       slots chan struct{}
+}
+
+// Summarize waits for a slot and builds the node with inner.
+func (s ProbeSlotSummarizer) Summarize(ctx context.Context, task Task) (string, error) {
+       select {
+       case s.slots <- struct{}{}:
+       case <-ctx.Done():
+               return "", ctx.Err()
+       }
+
+       defer func() {
+               <-s.slots
+       }()
+
+       return s.inner.Summarize(ctx, task)
+}
+
 // probe runs "onechat probe LOG COUNT [BUILDS]". It appends the first COUNT
 // messages of LOG, one JSON object {kind, text} per line, to a new chat in
 // probe/ in the data directory, and builds its tree with the real compactor.
 // probe runs "onechat probe LOG COUNT [BUILDS]". It appends the first COUNT
 // messages of LOG, one JSON object {kind, text} per line, to a new chat in
 // probe/ in the data directory, and builds its tree with the real compactor.
@@ -145,28 +167,6 @@ func probe(ctx context.Context, args []string, out io.Writer) (err error) {
        return nil
 }
 
        return nil
 }
 
-// ProbeSlotSummarizer lets at most cap(slots) builds call inner at once. A
-// build past the limit waits for a slot.
-type ProbeSlotSummarizer struct {
-       inner Summarizer
-       slots chan struct{}
-}
-
-// Summarize waits for a slot and builds the node with inner.
-func (s ProbeSlotSummarizer) Summarize(ctx context.Context, task Task) (string, error) {
-       select {
-       case s.slots <- struct{}{}:
-       case <-ctx.Done():
-               return "", ctx.Err()
-       }
-
-       defer func() {
-               <-s.slots
-       }()
-
-       return s.inner.Summarize(ctx, task)
-}
-
 // probeReadLog reads the first count messages of the probe log at path. Source
 // dates are ignored because a probe uses its own clock.
 func probeReadLog(path string, count int) (entries []DatedMessage, err error) {
 // probeReadLog reads the first count messages of the probe log at path. Source
 // dates are ignored because a probe uses its own clock.
 func probeReadLog(path string, count int) (entries []DatedMessage, err error) {