Skip to content

Commit

Permalink
feat: plugin 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 13, 2022
1 parent ee24a10 commit ce76a27
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 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 @@ -68,7 +67,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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module github.com/roadrunner-server/kv/v2
module github.com/roadrunner-server/kv/v3

go 1.19

require (
github.com/roadrunner-server/api/v2 v2.23.0
github.com/roadrunner-server/endure v1.4.5
github.com/roadrunner-server/errors v1.2.0
github.com/roadrunner-server/sdk/v3 v3.0.0-beta.4
go.buf.build/protocolbuffers/go/roadrunner-server/api v1.3.12
go.uber.org/zap v1.23.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
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/endure v1.4.5 h1:kInGwZc9Xd55gXsdAQonajz5I202MDyJdV+biJ6+asI=
github.com/roadrunner-server/endure v1.4.5/go.mod h1:FLqkppN/DAXhdMpuoVAlMt1L2odLCvCDRQr83gTHOl4=
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/v3 v3.0.0-beta.4 h1:jrBpY72kXYTkfQ00RME2HaW/m9+L4jYLujdkhW2/uwE=
github.com/roadrunner-server/sdk/v3 v3.0.0-beta.4/go.mod h1:QnhQ/Ib3uYXSVF0N9F7Accozx/nLkvRdGgufOJq5WfA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down
14 changes: 10 additions & 4 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package kv
import (
"fmt"

"github.com/roadrunner-server/api/v2/plugins/config"
"github.com/roadrunner-server/api/v2/plugins/kv"
endure "github.com/roadrunner-server/endure/pkg/container"
"github.com/roadrunner-server/errors"
"github.com/roadrunner-server/sdk/v3/plugins/kv"
"go.uber.org/zap"
)

Expand All @@ -19,6 +18,13 @@ const (
cfg string = "config"
)

type Configurer interface {
// UnmarshalKey takes a single key and unmarshal it into a Struct.
UnmarshalKey(name string, out any) error
// Has checks if config section exists.
Has(name string) bool
}

// Plugin for the unified storage
type Plugin struct {
log *zap.Logger
Expand All @@ -28,10 +34,10 @@ type Plugin struct {
storages map[string]kv.Storage
// KV configuration
cfg Config
cfgPlugin config.Configurer
cfgPlugin Configurer
}

func (p *Plugin) Init(cfg config.Configurer, log *zap.Logger) error {
func (p *Plugin) Init(cfg Configurer, log *zap.Logger) error {
const op = errors.Op("kv_plugin_init")
if !cfg.Has(PluginName) {
return errors.E(errors.Disabled)
Expand Down
2 changes: 1 addition & 1 deletion rpc.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kv

import (
"github.com/roadrunner-server/api/v2/plugins/kv"
"github.com/roadrunner-server/errors"
"github.com/roadrunner-server/sdk/v3/plugins/kv"
kvv1 "go.buf.build/protocolbuffers/go/roadrunner-server/api/proto/kv/v1"
)

Expand Down

0 comments on commit ce76a27

Please sign in to comment.