Skip to content

Commit 214d0a0

Browse files
committed
Switch to armon/circbuf
smallnest/ringbuffer requires you to manually reset.
1 parent 78234d4 commit 214d0a0

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ go 1.14
44

55
require (
66
cdr.dev/slog v1.3.0
7+
github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2
78
github.com/creack/pty v1.1.11
89
github.com/google/go-cmp v0.4.0
910
github.com/google/uuid v1.3.0
10-
github.com/smallnest/ringbuffer v0.0.0-20210227121335-0a58434b36f2
1111
github.com/spf13/pflag v1.0.5
1212
go.coder.com/cli v0.4.0
1313
go.coder.com/flog v0.0.0-20190906214207-47dd47ea0512

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUS
3030
github.com/alecthomas/kong-hcl v0.1.8-0.20190615233001-b21fea9723c8/go.mod h1:MRgZdU3vrFd05IQ89AxUZ0aYdF39BYoNFa324SodPCA=
3131
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
3232
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
33+
github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2 h1:7Ip0wMmLHLRJdrloDxZfhMm0xrLXZS8+COSu2bXmEQs=
34+
github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
3335
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
3436
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
3537
github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw=
@@ -141,8 +143,6 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
141143
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
142144
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
143145
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
144-
github.com/smallnest/ringbuffer v0.0.0-20210227121335-0a58434b36f2 h1:co1YnJJ6rDvcodJzcXObchJMfHclIROMulsWObuNfTY=
145-
github.com/smallnest/ringbuffer v0.0.0-20210227121335-0a58434b36f2/go.mod h1:mXcZNMJHswhQDDJZIjdtJoG97JIwIa/HdcHNM3w15T0=
146146
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
147147
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
148148
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=

server.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"sync"
1111
"time"
1212

13+
"github.com/armon/circbuf"
1314
"github.com/google/uuid"
14-
"github.com/smallnest/ringbuffer"
1515

1616
"go.coder.com/flog"
1717
"golang.org/x/sync/errgroup"
@@ -110,11 +110,16 @@ func Serve(ctx context.Context, c *websocket.Conn, execer Execer, options *Optio
110110
return err
111111
}
112112

113+
ringBuffer, err := circbuf.NewBuffer(1 << 20)
114+
if err != nil {
115+
return xerrors.Errorf("unable to create ring buffer %w", err)
116+
}
117+
113118
rprocess = &reconnectingProcess{
114119
activeConns: make(map[string]net.Conn),
115120
process: process,
116121
// Default to buffer 1MB.
117-
ringBuffer: ringbuffer.New(1 << 20),
122+
ringBuffer: ringBuffer,
118123
}
119124
reconnectingProcesses.Store(header.ID, rprocess)
120125
go func() {
@@ -295,7 +300,7 @@ type reconnectingProcess struct {
295300
activeConnsMutex sync.Mutex
296301
activeConns map[string]net.Conn
297302

298-
ringBuffer *ringbuffer.RingBuffer
303+
ringBuffer *circbuf.Buffer
299304
timeoutCancel context.CancelFunc
300305
process Process
301306
}

0 commit comments

Comments
 (0)