diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index e0578df..d8b0ff8 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -12,7 +12,7 @@ on: jobs: ci: - name: Vet, lint and test + name: Vet, Lint, Test and Vulnerability Check runs-on: ubuntu-latest steps: - name: Checkout repo @@ -36,18 +36,17 @@ jobs: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin golangci-lint run --out-format=github-actions + - name: Vulnerability Check + uses: golang/govulncheck-action@v1 + with: + go-package: ./... + go-version-input: ">=1.21.0" + check-latest: true + - name: Integration Tests run: make test_integration - name: Recovery Tests run: make test_recovery - govulncheck: - runs-on: ubuntu-latest - name: Run govulncheck - steps: - - id: govulncheck - uses: golang/govulncheck-action@v1 - with: - go-package: ./... - check-latest: true + diff --git a/clarimq_test.go b/clarimq_test.go index dcf07b2..0359ee3 100644 --- a/clarimq_test.go +++ b/clarimq_test.go @@ -1142,7 +1142,7 @@ func Test_Integration_DeadLetterRetry(t *testing.T) { handler := func(delivery *clarimq.Delivery) clarimq.Action { requireEqual(t, testMessage, string(delivery.Body)) - retryCount, _ := delivery.Headers["x-retry-count"].(int32) + retryCount, _ := delivery.Headers["x-retry-count"].(int32) //nolint:revive // test code if retryCount < 2 { return clarimq.NackDiscard diff --git a/connection_options.go b/connection_options.go index 50153e7..0a84b95 100644 --- a/connection_options.go +++ b/connection_options.go @@ -180,3 +180,52 @@ func WithConnectionOptionMaxRecoveryRetries(maxRetries int) ConnectionOption { func WithConnectionOptionBackOffFactor(factor int) ConnectionOption { return func(options *ConnectionOptions) { options.BackOffFactor = factor } } + +// SetLoggers provides possibility to add loggers. +func (c *Connection) SetLoggers(loggers []*slog.Logger) { + if len(loggers) > 0 { + c.options.loggers = loggers + } +} + +// SetReturnHandler provides possibility to set the json encoder. +func (c *Connection) SetEncoder(encoder JSONEncoder) { + if encoder != nil { + c.options.codec.Encoder = encoder + } +} + +// SetReturnHandler provides possibility to set the json decoder. +func (c *Connection) SetDecoder(decoder JSONDecoder) { + if decoder != nil { + c.options.codec.Decoder = decoder + } +} + +// SetReturnHandler provides possibility to add a return handler. +func (c *Connection) SetReturnHandler(returnHandler ReturnHandler) { + if returnHandler != nil { + c.returnHandler = returnHandler + } +} + +// SetRecoveryInterval sets the recovery interval. +// +// Default: 1s. +func (c *Connection) SetRecoveryInterval(interval time.Duration) { + c.options.RecoveryInterval = interval +} + +// SetMaxRecoveryRetries sets the limit for maximum retries. +// +// Default: 10. +func (c *Connection) SetMaxRecoveryRetries(maxRetries int) { + c.options.MaxRecoveryRetries = maxRetries +} + +// SetBackOffFactor sets the exponential back-off factor. +// +// Default: 2. +func (c *Connection) SetBackOffFactor(factor int) { + c.options.BackOffFactor = factor +} diff --git a/publish_options.go b/publish_options.go index df79f9d..ba3b90f 100644 --- a/publish_options.go +++ b/publish_options.go @@ -9,7 +9,7 @@ type ( // could not be published due to a missing broker connection. PublishingCache interface { // Put adds a publishing to the cache. - Put(Publishing) error + Put(p Publishing) error // PopAll gets all publishing's from the cache and removes them. PopAll() ([]Publishing, error) // Len returns the number of publishing in the cache.