feat(sbc): add upsert worker storage bucket job
This commit is contained in:
1 parent
670a43ca22
commit
9bc5e492f6
10 files changed
+272
-136
No files matched your search
@@ -9,17 +9,19 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
)
|
||||
|
||||
type Repository struct {
|
||||
reader db.Reader
|
||||
writer db.Writer
|
||||
kms *kms.Kms
|
||||
reader db.Reader
|
||||
writer db.Writer
|
||||
kms *kms.Kms
|
||||
scheduler *scheduler.Scheduler
|
||||
}
|
||||
|
||||
// NewRepository creates a new Repository. The returned repository is not
|
||||
// safe for concurrent go routines to access it
|
||||
func NewRepository(ctx context.Context, r db.Reader, w db.Writer, kms *kms.Kms) (*Repository, error) {
|
||||
func NewRepository(ctx context.Context, r db.Reader, w db.Writer, kms *kms.Kms, scheduler *scheduler.Scheduler) (*Repository, error) {
|
||||
const op = "plugin.NewRepository"
|
||||
switch {
|
||||
case r == nil:
|
||||
@@ -28,11 +30,14 @@ func NewRepository(ctx context.Context, r db.Reader, w db.Writer, kms *kms.Kms)
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "nil db.Writer")
|
||||
case kms == nil:
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "nil kms")
|
||||
case scheduler == nil:
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "scheduler")
|
||||
}
|
||||
|
||||
return &Repository{
|
||||
reader: r,
|
||||
writer: w,
|
||||
kms: kms,
|
||||
reader: r,
|
||||
writer: w,
|
||||
kms: kms,
|
||||
scheduler: scheduler,
|
||||
}, nil
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -19,6 +20,7 @@ func TestRepository_NewRepository(t *testing.T) {
|
||||
rw := db.New(conn)
|
||||
wrapper := db.TestWrapper(t)
|
||||
kmsCache := kms.TestKms(t, conn, wrapper)
|
||||
sche := scheduler.TestScheduler(t, conn, wrapper)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -74,7 +76,7 @@ func TestRepository_NewRepository(t *testing.T) {
|
||||
require, assert := require.New(t), assert.New(t)
|
||||
ctx := context.Background()
|
||||
|
||||
repo, err := NewRepository(ctx, tt.in.reader, tt.in.writer, tt.in.kms)
|
||||
repo, err := NewRepository(ctx, tt.in.reader, tt.in.writer, tt.in.kms, sche)
|
||||
if tt.wantErrContains != "" {
|
||||
require.ErrorContains(err, tt.wantErrContains)
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user