this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

keep trying to consume until cancelled

+12 -21
+2 -5
go.mod
··· 1 - module github.com/willdot/bksyfeedgen 1 + module github.com/willdot/bskyfeedgen 2 2 3 3 go 1.22.0 4 4 5 5 require ( 6 + github.com/avast/retry-go/v4 v4.6.0 6 7 github.com/bluesky-social/indigo v0.0.0-20241031232035-1a73c3fb6841 7 8 github.com/bluesky-social/jetstream v0.0.0-20241031234625-0ab10bd041fe 8 9 github.com/golang-jwt/jwt/v5 v5.2.1 9 10 github.com/gorilla/websocket v1.5.1 10 - github.com/stretchr/testify v1.9.0 11 11 ) 12 12 13 13 require ( 14 14 github.com/beorn7/perks v1.0.1 // indirect 15 15 github.com/carlmjohnson/versioninfo v0.22.5 // indirect 16 16 github.com/cespare/xxhash/v2 v2.3.0 // indirect 17 - github.com/davecgh/go-spew v1.1.1 // indirect 18 17 github.com/felixge/httpsnoop v1.0.4 // indirect 19 18 github.com/go-logr/logr v1.4.1 // indirect 20 19 github.com/go-logr/stdr v1.2.2 // indirect ··· 49 48 github.com/multiformats/go-multihash v0.2.3 // indirect 50 49 github.com/multiformats/go-varint v0.0.7 // indirect 51 50 github.com/opentracing/opentracing-go v1.2.0 // indirect 52 - github.com/pmezard/go-difflib v1.0.0 // indirect 53 51 github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f // indirect 54 52 github.com/prometheus/client_golang v1.19.1 // indirect 55 53 github.com/prometheus/client_model v0.6.1 // indirect ··· 72 70 golang.org/x/time v0.5.0 // indirect 73 71 golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect 74 72 google.golang.org/protobuf v1.34.2 // indirect 75 - gopkg.in/yaml.v3 v3.0.1 // indirect 76 73 lukechampine.com/blake3 v1.2.1 // indirect 77 74 )
+2
go.sum
··· 1 1 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 2 + github.com/avast/retry-go/v4 v4.6.0 h1:K9xNA+KeB8HHc2aWFuLb25Offp+0iVRXEvFx8IinRJA= 3 + github.com/avast/retry-go/v4 v4.6.0/go.mod h1:gvWlPhBVsvBbLkVGDg/KwvBv0bEkCOLRRSHKIr2PyOE= 2 4 github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= 3 5 github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= 4 6 github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
+8 -16
main.go
··· 8 8 "os/signal" 9 9 "syscall" 10 10 11 - "github.com/gorilla/websocket" 11 + "github.com/avast/retry-go/v4" 12 12 ) 13 13 14 14 const ( ··· 51 51 52 52 func consumeLoop(ctx context.Context, jsServerAddr string, feeder *FeedGenerator) { 53 53 consumer := NewConsumer(jsServerAddr) 54 - continueCount := 0 55 - for { 54 + 55 + retry.Do(func() error { 56 56 err := consumer.Consume(ctx, feeder, slog.Default()) 57 57 if err != nil { 58 58 if errors.Is(err, context.Canceled) { 59 - return 60 - } 61 - 62 - var closeErr *websocket.CloseError 63 - if errors.As(err, &closeErr) { 64 - if closeErr.Code == websocket.CloseAbnormalClosure && continueCount <= 100 { 65 - slog.Error("consume - trying again", "error", err) 66 - continueCount++ 67 - continue 68 - } 59 + return nil 69 60 } 70 - slog.Error("consume - exiting gracefully", "error", err) 71 - return 61 + slog.Error("consume loop", "error", err) 62 + return err 72 63 } 73 - } 64 + return nil 65 + }, retry.Attempts(0)) 74 66 }