private/context2: moved to storj.io/common/context2
Change-Id: Ic1dd1ed645ff3e1057c9b2b143e2c3ddf29d678e
This commit is contained in:
parent
d994584e88
commit
1b6ab173a8
@ -8,9 +8,9 @@ import (
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/common/context2"
|
||||
"storj.io/storj/pkg/process"
|
||||
"storj.io/storj/pkg/revocation"
|
||||
"storj.io/storj/private/context2"
|
||||
"storj.io/storj/private/version"
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/satellite/accounting/live"
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/common/context2"
|
||||
"storj.io/common/fpath"
|
||||
"storj.io/common/storj"
|
||||
"storj.io/storj/cmd/satellite/reports"
|
||||
@ -23,7 +24,6 @@ import (
|
||||
"storj.io/storj/pkg/cfgstruct"
|
||||
"storj.io/storj/pkg/process"
|
||||
"storj.io/storj/pkg/revocation"
|
||||
"storj.io/storj/private/context2"
|
||||
"storj.io/storj/private/version"
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/satellite/accounting/live"
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/common/context2"
|
||||
"storj.io/storj/pkg/process"
|
||||
"storj.io/storj/pkg/revocation"
|
||||
"storj.io/storj/private/context2"
|
||||
"storj.io/storj/private/version"
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/satellite/metainfo"
|
||||
|
2
go.mod
2
go.mod
@ -54,7 +54,7 @@ require (
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
|
||||
google.golang.org/grpc v1.27.1
|
||||
gopkg.in/yaml.v2 v2.2.4
|
||||
storj.io/common v0.0.0-20200319165559-1fc2508a7284
|
||||
storj.io/common v0.0.0-20200320083002-07faa8a64ad8
|
||||
storj.io/drpc v0.0.8
|
||||
storj.io/uplink v1.0.0
|
||||
)
|
||||
|
2
go.sum
2
go.sum
@ -585,6 +585,8 @@ storj.io/common v0.0.0-20200318103328-b7e942ff9304 h1:KQ1ITzbT32bAyBx5gPYQFkMs86
|
||||
storj.io/common v0.0.0-20200318103328-b7e942ff9304/go.mod h1:I0QTs7z1rI+ZEN95GGY2LKMzP5OZqu0Udga3WhyQfO0=
|
||||
storj.io/common v0.0.0-20200319165559-1fc2508a7284 h1:Bym7jVTXPdZ5cHEH3tey/RR5ps3vG1Ru9ucDVlJWIxs=
|
||||
storj.io/common v0.0.0-20200319165559-1fc2508a7284/go.mod h1:I0QTs7z1rI+ZEN95GGY2LKMzP5OZqu0Udga3WhyQfO0=
|
||||
storj.io/common v0.0.0-20200320083002-07faa8a64ad8 h1:DgWXFCldvyu1drZKKL0D3vlHSkjmBsvBqr8nXg59SFs=
|
||||
storj.io/common v0.0.0-20200320083002-07faa8a64ad8/go.mod h1:I0QTs7z1rI+ZEN95GGY2LKMzP5OZqu0Udga3WhyQfO0=
|
||||
storj.io/drpc v0.0.7-0.20191115031725-2171c57838d2/go.mod h1:/ascUDbzNAv0A3Jj7wUIKFBH2JdJ2uJIBO/b9+2yHgQ=
|
||||
storj.io/drpc v0.0.8 h1:wu68cMmtoT0vSWIAZz29RpJkWdi4o0S8BIrLslpH5FQ=
|
||||
storj.io/drpc v0.0.8/go.mod h1:v39uWro/EbXXk+gNnrM9FQuVVS2zUBWBfeduydgeXUA=
|
||||
|
@ -1,49 +0,0 @@
|
||||
// Copyright (C) 2020 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
// Package context2 contains utilities for contexts.
|
||||
package context2
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// WithoutCancellation returns a context that does not propagate Done message
|
||||
// down to children. However, Values are propagated.
|
||||
func WithoutCancellation(ctx context.Context) context.Context {
|
||||
return noCancelContext{ctx}
|
||||
}
|
||||
|
||||
type noCancelContext struct {
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
// Deadline returns the time when work done on behalf of this context
|
||||
// should be canceled.
|
||||
func (noCancelContext) Deadline() (deadline time.Time, ok bool) {
|
||||
return time.Time{}, false
|
||||
}
|
||||
|
||||
// Done returns empty channel.
|
||||
func (noCancelContext) Done() <-chan struct{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Err always returns nil
|
||||
func (noCancelContext) Err() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// String returns string.
|
||||
func (ctx noCancelContext) String() string {
|
||||
return fmt.Sprintf("no cancel (%s)", ctx.ctx)
|
||||
}
|
||||
|
||||
// Value returns the value associated with this context for key, or nil
|
||||
// if no value is associated with key. Successive calls to Value with
|
||||
// the same key returns the same result.
|
||||
func (ctx noCancelContext) Value(key interface{}) interface{} {
|
||||
return ctx.ctx.Value(key)
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
// Copyright (C) 2020 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package context2_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"storj.io/common/testcontext"
|
||||
"storj.io/storj/private/context2"
|
||||
)
|
||||
|
||||
func TestWithoutCancellation(t *testing.T) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
parent, cancel := context.WithCancel(ctx)
|
||||
cancel()
|
||||
|
||||
without := context2.WithoutCancellation(parent)
|
||||
require.Equal(t, error(nil), without.Err())
|
||||
require.Equal(t, (<-chan struct{})(nil), without.Done())
|
||||
}
|
@ -8,8 +8,8 @@ import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
|
||||
"storj.io/common/context2"
|
||||
"storj.io/storj/pkg/traces"
|
||||
"storj.io/storj/private/context2"
|
||||
)
|
||||
|
||||
// Conn is an interface for *sql.Conn-like connections.
|
||||
|
@ -14,8 +14,8 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"storj.io/common/context2"
|
||||
"storj.io/storj/pkg/traces"
|
||||
"storj.io/storj/private/context2"
|
||||
)
|
||||
|
||||
// Open opens *sql.DB and wraps the implementation with tagging.
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/common/context2"
|
||||
"storj.io/common/errs2"
|
||||
"storj.io/common/pb"
|
||||
"storj.io/common/rpc/rpcstatus"
|
||||
@ -24,7 +25,6 @@ import (
|
||||
"storj.io/common/storj"
|
||||
lrucache "storj.io/storj/pkg/cache"
|
||||
"storj.io/storj/pkg/macaroon"
|
||||
"storj.io/storj/private/context2"
|
||||
"storj.io/storj/private/dbutil"
|
||||
"storj.io/storj/satellite/accounting"
|
||||
"storj.io/storj/satellite/attribution"
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"storj.io/common/bloomfilter"
|
||||
"storj.io/common/context2"
|
||||
"storj.io/common/errs2"
|
||||
"storj.io/common/identity"
|
||||
"storj.io/common/memory"
|
||||
@ -26,7 +27,6 @@ import (
|
||||
"storj.io/common/signing"
|
||||
"storj.io/common/storj"
|
||||
"storj.io/common/sync2"
|
||||
"storj.io/storj/private/context2"
|
||||
"storj.io/storj/storagenode/bandwidth"
|
||||
"storj.io/storj/storagenode/monitor"
|
||||
"storj.io/storj/storagenode/orders"
|
||||
|
Loading…
Reference in New Issue
Block a user