Skip to content

Commit

Permalink
feat: update to v3
Browse files Browse the repository at this point in the history
Signed-off-by: Valery Piashchynski <[email protected]>
  • Loading branch information
rustatian committed Oct 9, 2022
1 parent 7b94068 commit e255ed8
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
- name: Run linter
uses: golangci/[email protected] # Action page: <https://github.com/golangci/golangci-lint-action>
with:
version: v1.49 # without patch version
version: v1.50 # without patch version
only-new-issues: false # show only new issues if it's a pull request
args: --timeout=10m --build-tags=race
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Documentation: <https://github.com/golangci/golangci-lint#config-file>

run:
go: '1.17'
timeout: 1m
skip-dirs:
- .github
Expand Down Expand Up @@ -71,7 +70,6 @@ linters: # All available linters list: <https://golangci-lint.run/usage/linters/
- noctx # finds sending http request without context.Context
- nolintlint # Reports ill-formed or insufficient nolint directives
- prealloc # Finds slice declarations that could potentially be preallocated
- rowserrcheck # Checks whether Err of rows is checked successfully
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
- stylecheck # Stylecheck is a replacement for golint
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
Expand Down
2 changes: 1 addition & 1 deletion beanstalkjobs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package beanstalkjobs
import (
"time"

"github.com/roadrunner-server/sdk/v2/utils"
"github.com/roadrunner-server/sdk/v3/utils"
)

const (
Expand Down
21 changes: 14 additions & 7 deletions beanstalkjobs/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,26 @@ import (
"sync/atomic"
"time"

cfgPlugin "github.com/roadrunner-server/api/v2/plugins/config"
"github.com/roadrunner-server/api/v2/plugins/jobs"
"github.com/roadrunner-server/api/v2/plugins/jobs/pipeline"
priorityqueue "github.com/roadrunner-server/api/v2/pq"
"github.com/roadrunner-server/errors"
"github.com/roadrunner-server/sdk/v2/utils"
"github.com/roadrunner-server/sdk/v3/plugins/jobs"
"github.com/roadrunner-server/sdk/v3/plugins/jobs/pipeline"
priorityqueue "github.com/roadrunner-server/sdk/v3/priority_queue"
"github.com/roadrunner-server/sdk/v3/utils"
"go.uber.org/zap"
)

const (
pluginName string = "beanstalk"
)

type Configurer interface {
// UnmarshalKey takes a single key and unmarshals it into a Struct.
UnmarshalKey(name string, out any) error

// Has checks if config section exists.
Has(name string) bool
}

type Consumer struct {
log *zap.Logger
pq priorityqueue.Queue
Expand All @@ -45,7 +52,7 @@ type Consumer struct {
stopCh chan struct{}
}

func NewBeanstalkConsumer(configKey string, log *zap.Logger, cfg cfgPlugin.Configurer, pq priorityqueue.Queue) (*Consumer, error) {
func NewBeanstalkConsumer(configKey string, log *zap.Logger, cfg Configurer, pq priorityqueue.Queue) (*Consumer, error) {
const op = errors.Op("new_beanstalk_consumer")

// PARSE CONFIGURATION -------
Expand Down Expand Up @@ -105,7 +112,7 @@ func NewBeanstalkConsumer(configKey string, log *zap.Logger, cfg cfgPlugin.Confi
return jc, nil
}

func FromPipeline(pipe *pipeline.Pipeline, log *zap.Logger, cfg cfgPlugin.Configurer, pq priorityqueue.Queue) (*Consumer, error) {
func FromPipeline(pipe *pipeline.Pipeline, log *zap.Logger, cfg Configurer, pq priorityqueue.Queue) (*Consumer, error) {
const op = errors.Op("new_beanstalk_consumer")

// PARSE CONFIGURATION -------
Expand Down
4 changes: 2 additions & 2 deletions beanstalkjobs/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/beanstalkd/go-beanstalk"
"github.com/goccy/go-json"
"github.com/google/uuid"
"github.com/roadrunner-server/api/v2/plugins/jobs"
"github.com/roadrunner-server/sdk/v2/utils"
"github.com/roadrunner-server/sdk/v3/plugins/jobs"
"github.com/roadrunner-server/sdk/v3/utils"
"go.uber.org/zap"
)

Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ require (
github.com/cenkalti/backoff/v4 v4.1.3
github.com/goccy/go-json v0.9.11
github.com/google/uuid v1.3.0
github.com/roadrunner-server/api/v2 v2.23.0
github.com/roadrunner-server/errors v1.2.0
github.com/roadrunner-server/sdk/v2 v2.19.0
github.com/roadrunner-server/sdk/v3 v3.0.0-beta.3
go.uber.org/zap v1.23.0
)

Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/roadrunner-server/api/v2 v2.23.0 h1:FCpVZWl7fZZqBdD/Z4HCVgQ+vKbqARneji20mp3iqDM=
github.com/roadrunner-server/api/v2 v2.23.0/go.mod h1:UrOUfDFw0927h/PWv7f8PPcwfdHkwf8txWbmqszL7UA=
github.com/roadrunner-server/errors v1.2.0 h1:qBmNXt8Iex9QnYTjCkbJKsBZu2EtYkQCM06GUDcQBbI=
github.com/roadrunner-server/errors v1.2.0/go.mod h1:z0ECxZp/dDa5RahtMcy4mBIavVxiZ9vwE5kByl7kFtY=
github.com/roadrunner-server/sdk/v2 v2.19.0 h1:ODeNTR0002SDAMsn6YeDw94kSQbhJf8qJ8o+J90ucwQ=
github.com/roadrunner-server/sdk/v2 v2.19.0/go.mod h1:7mS8y12roUB8T4c66+yf+qoIVhmIa3E2fByUcYP1DxQ=
github.com/roadrunner-server/sdk/v3 v3.0.0-beta.3 h1:v3JRjemghzdQr1+XpvS/2kkLRuRNhoOxYB7+cvIpNzg=
github.com/roadrunner-server/sdk/v3 v3.0.0-beta.3/go.mod h1:TEQZXEEMfEObT4e9tjyFVTOsOhO22yl+2NNZFZT2B5w=
github.com/roadrunner-server/tcplisten v1.2.0 h1:nsiXEEb0zP7vjAsCWNHKpM0HdwFK/KlafFF/2gsTJlg=
github.com/roadrunner-server/tcplisten v1.2.0/go.mod h1:NhumKvt7dbIKVNZnqR1fA4ET1D8ngIKsg0TxnuJTL6A=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
27 changes: 13 additions & 14 deletions plugin.go
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
package beanstalk

import (
cfgPlugin "github.com/roadrunner-server/api/v2/plugins/config"
"github.com/roadrunner-server/api/v2/plugins/jobs"
"github.com/roadrunner-server/api/v2/plugins/jobs/pipeline"
priorityqueue "github.com/roadrunner-server/api/v2/pq"
"github.com/roadrunner-server/beanstalk/v2/beanstalkjobs"
"github.com/roadrunner-server/sdk/v3/plugins/jobs"
"github.com/roadrunner-server/sdk/v3/plugins/jobs/pipeline"
priorityqueue "github.com/roadrunner-server/sdk/v3/priority_queue"
"go.uber.org/zap"
)

const (
pluginName string = "beanstalk"
)

type Configurer interface {
// UnmarshalKey takes a single key and unmarshals it into a Struct.
UnmarshalKey(name string, out any) error

// Has checks if config section exists.
Has(name string) bool
}

type Plugin struct {
log *zap.Logger
cfg cfgPlugin.Configurer
cfg Configurer
}

func (p *Plugin) Init(log *zap.Logger, cfg cfgPlugin.Configurer) error {
func (p *Plugin) Init(log *zap.Logger, cfg Configurer) error {
p.log = new(zap.Logger)
*p.log = *log
p.cfg = cfg
return nil
}

func (p *Plugin) Serve() chan error {
return make(chan error)
}

func (p *Plugin) Stop() error {
return nil
}

func (p *Plugin) Name() string {
return pluginName
}
Expand Down

0 comments on commit e255ed8

Please sign in to comment.