core: Remove the redundant With* methods on context.
Change-Id: I306f884f28dec1562e40b924b853365ea153a512
MultiPart: 3/4
diff --git a/runtimes/google/ipc/cancel_test.go b/runtimes/google/ipc/cancel_test.go
index 0dcf6d8..31d5abc 100644
--- a/runtimes/google/ipc/cancel_test.go
+++ b/runtimes/google/ipc/cancel_test.go
@@ -6,6 +6,7 @@
"v.io/core/veyron/runtimes/google/ipc/stream/manager"
tnaming "v.io/core/veyron/runtimes/google/testing/mocks/naming"
+ "v.io/core/veyron2/context"
"v.io/core/veyron2/ipc"
"v.io/core/veyron2/ipc/stream"
"v.io/core/veyron2/naming"
@@ -103,7 +104,7 @@
}
defer c2.stop()
- ctx, cancel := testContext().WithCancel()
+ ctx, cancel := context.WithCancel(testContext())
_, err = client.StartCall(ctx, "c1", "Run", []interface{}{})
if err != nil {
t.Fatal("can't call: ", err)
diff --git a/runtimes/google/ipc/client_test.go b/runtimes/google/ipc/client_test.go
index 137acad..0819f88 100644
--- a/runtimes/google/ipc/client_test.go
+++ b/runtimes/google/ipc/client_test.go
@@ -10,6 +10,7 @@
"time"
"v.io/core/veyron2"
+ "v.io/core/veyron2/context"
"v.io/core/veyron2/naming"
"v.io/core/veyron2/rt"
verror "v.io/core/veyron2/verror2"
@@ -150,7 +151,7 @@
func TestTimeoutCall(t *testing.T) {
client := r.Client()
- ctx, _ := r.NewContext().WithTimeout(100 * time.Millisecond)
+ ctx, _ := context.WithTimeout(r.NewContext(), 100*time.Millisecond)
name := naming.JoinAddressName(naming.FormatEndpoint("tcp", "203.0.113.10:443"), "")
_, err := client.StartCall(ctx, name, "echo", []interface{}{"args don't matter"})
if !verror.Is(err, verror.Timeout.ID) {
@@ -218,7 +219,7 @@
func TestTimeoutResponse(t *testing.T) {
name, fn := initServer(t, r)
defer fn()
- ctx, _ := r.NewContext().WithTimeout(100 * time.Millisecond)
+ ctx, _ := context.WithTimeout(r.NewContext(), 100*time.Millisecond)
call, err := r.Client().StartCall(ctx, name, "Sleep", nil)
if err != nil {
testForVerror(t, err, verror.Timeout, verror.BadProtocol)
@@ -273,7 +274,7 @@
name, fn := initServer(t, r)
defer fn()
- ctx, cancel := r.NewContext().WithCancel()
+ ctx, cancel := context.WithCancel(r.NewContext())
call, err := r.Client().StartCall(ctx, name, "Sleep", nil)
if err != nil {
t.Fatalf("unexpected error: %s", err)
@@ -289,7 +290,7 @@
name, fn := initServer(t, r)
defer fn()
- ctx, cancel := r.NewContext().WithCancel()
+ ctx, cancel := context.WithCancel(r.NewContext())
call, err := r.Client().StartCall(ctx, name, "Sleep", nil)
if err != nil {
t.Fatalf("unexpected error: %s", err)
@@ -360,7 +361,7 @@
defer fn()
want := 10
- ctx, _ := r.NewContext().WithTimeout(300 * time.Millisecond)
+ ctx, _ := context.WithTimeout(r.NewContext(), 300*time.Millisecond)
call, err := r.Client().StartCall(ctx, name, "Source", []interface{}{want})
if err != nil {
if !verror.Is(err, verror.Timeout.ID) && !verror.Is(err, verror.BadProtocol.ID) {
@@ -430,7 +431,7 @@
_, fn := runMountTable(t, r)
defer fn()
name := "noservers"
- ctx, _ := r.NewContext().WithTimeout(300 * time.Millisecond)
+ ctx, _ := context.WithTimeout(r.NewContext(), 300*time.Millisecond)
call, verr := r.Client().StartCall(ctx, name, "Sleep", nil)
if verr != nil {
testForVerror(t, verr, verror.Timeout, verror.BadProtocol, verror.NoExist)
@@ -445,7 +446,7 @@
name := "a_mount_table_entry"
// If there is no mount table, then we'll get a NoServers error message.
- ctx, _ := r.NewContext().WithTimeout(300 * time.Millisecond)
+ ctx, _ := context.WithTimeout(r.NewContext(), 300*time.Millisecond)
_, verr := r.Client().StartCall(ctx, name, "Sleep", nil)
testForVerror(t, verr, verror.NoServers)
}
diff --git a/runtimes/google/ipc/full_test.go b/runtimes/google/ipc/full_test.go
index 259a45e..eced2ae 100644
--- a/runtimes/google/ipc/full_test.go
+++ b/runtimes/google/ipc/full_test.go
@@ -82,7 +82,7 @@
// so we use a fake one that panics if used. The runtime
// implementation should not ever use the Runtime from a context.
func testContext() *context.T {
- ctx, _ := testContextWithoutDeadline().WithTimeout(20 * time.Second)
+ ctx, _ := context.WithTimeout(testContextWithoutDeadline(), 20*time.Second)
return ctx
}
@@ -480,7 +480,7 @@
continue
}
ctx := testContextWithoutDeadline()
- dctx, cancel := ctx.WithTimeout(10 * time.Second)
+ dctx, cancel := context.WithTimeout(ctx, 10*time.Second)
call, err := client.StartCall(dctx, fmt.Sprintf("[%s]%s/suffix", test.pattern, serverName), "Method", nil)
if !matchesErrorPattern(err, test.errID, test.err) {
t.Errorf(`%d: %s: client.StartCall: got error "%v", want to match "%v"`, i, name, err, test.err)
@@ -1099,7 +1099,7 @@
b := createBundle(t, tsecurity.NewPrincipal("client"), tsecurity.NewPrincipal("server"), ts)
defer b.cleanup(t)
- ctx, cancel := testContext().WithCancel()
+ ctx, cancel := context.WithCancel(testContext())
_, err := b.client.StartCall(ctx, "mountpoint/server/suffix", "CancelStreamReader", []interface{}{})
if err != nil {
t.Fatalf("Start call failed: %v", err)
@@ -1114,7 +1114,7 @@
b := createBundle(t, tsecurity.NewPrincipal("client"), tsecurity.NewPrincipal("server"), ts)
defer b.cleanup(t)
- ctx, cancel := testContext().WithCancel()
+ ctx, cancel := context.WithCancel(testContext())
call, err := b.client.StartCall(ctx, "mountpoint/server/suffix", "CancelStreamIgnorer", []interface{}{})
if err != nil {
t.Fatalf("Start call failed: %v", err)
@@ -1191,7 +1191,7 @@
publisher.AddServer("/@2@tcp@localhost:10000@@1000000@2000000@@", false)
publisher.AddServer("/@2@tcp@localhost:10001@@2000000@3000000@@", false)
- ctx, _ := testContext().WithTimeout(100 * time.Millisecond)
+ ctx, _ := context.WithTimeout(testContext(), 100*time.Millisecond)
_, err := b.client.StartCall(ctx, "incompatible/suffix", "Echo", []interface{}{"foo"})
if !verror.Is(err, verror.NoServers.ID) {
diff --git a/runtimes/google/ipc/server.go b/runtimes/google/ipc/server.go
index 0b85a52..f4017d0 100644
--- a/runtimes/google/ipc/server.go
+++ b/runtimes/google/ipc/server.go
@@ -976,9 +976,9 @@
var cancel context.CancelFunc
if req.Timeout != ipc.NoTimeout {
- fs.T, cancel = fs.WithDeadline(fs.starttime.Add(time.Duration(req.Timeout)))
+ fs.T, cancel = context.WithDeadline(fs.T, fs.starttime.Add(time.Duration(req.Timeout)))
} else {
- fs.T, cancel = fs.WithCancel()
+ fs.T, cancel = context.WithCancel(fs.T)
}
fs.flow.SetDeadline(fs.Done())
go fs.cancelContextOnClose(cancel)
diff --git a/runtimes/google/ipc/server_test.go b/runtimes/google/ipc/server_test.go
index 4a8e393..dddc68e 100644
--- a/runtimes/google/ipc/server_test.go
+++ b/runtimes/google/ipc/server_test.go
@@ -9,6 +9,7 @@
"testing"
"time"
+ "v.io/core/veyron2/context"
"v.io/core/veyron2/ipc"
"v.io/core/veyron2/naming"
@@ -44,7 +45,7 @@
serverEP := session.ExpectVar("ADDR")
ep, _ := inaming.NewEndpoint(serverEP)
makeCall := func() (string, error) {
- ctx, _ := testContext().WithDeadline(time.Now().Add(10 * time.Second))
+ ctx, _ := context.WithDeadline(testContext(), time.Now().Add(10*time.Second))
call, err := b.client.StartCall(ctx, serverName, "Echo", []interface{}{"bratman"})
if err != nil {
return "", fmt.Errorf("START: %s", err)
@@ -164,7 +165,7 @@
name := "mountpoint/server/suffix"
makeCall := func() (string, error) {
- ctx, _ := testContext().WithDeadline(time.Now().Add(5 * time.Second))
+ ctx, _ := context.WithDeadline(testContext(), time.Now().Add(5*time.Second))
// Let's fail fast so that the tests don't take as long to run.
call, err := client.StartCall(ctx, name, "Echo", []interface{}{"batman"})
if err != nil {
diff --git a/runtimes/google/lib/publisher/publisher_test.go b/runtimes/google/lib/publisher/publisher_test.go
index cf00157..a82e4ca 100644
--- a/runtimes/google/lib/publisher/publisher_test.go
+++ b/runtimes/google/lib/publisher/publisher_test.go
@@ -18,7 +18,7 @@
func testContext() *context.T {
ctx := context.NewUninitializedContext(&runtime.PanicRuntime{})
ctx, _ = vtrace.WithNewSpan(ctx, "")
- ctx, _ = ctx.WithDeadline(time.Now().Add(20 * time.Second))
+ ctx, _ = context.WithDeadline(ctx, time.Now().Add(20*time.Second))
return ctx
}
diff --git a/runtimes/google/naming/namespace/glob.go b/runtimes/google/naming/namespace/glob.go
index 6d15ed7..d4825fe 100644
--- a/runtimes/google/naming/namespace/glob.go
+++ b/runtimes/google/naming/namespace/glob.go
@@ -55,7 +55,7 @@
}
// Don't further resolve s.Server.
- callCtx, _ := ctx.WithTimeout(callTimeout)
+ callCtx, _ := context.WithTimeout(ctx, callTimeout)
call, err := client.StartCall(callCtx, s.Server, ipc.GlobMethod, []interface{}{pstr}, options.NoResolve(true))
if err != nil {
lastErr = err
diff --git a/runtimes/google/naming/namespace/mount.go b/runtimes/google/naming/namespace/mount.go
index eb126dc..0182a2a 100644
--- a/runtimes/google/naming/namespace/mount.go
+++ b/runtimes/google/naming/namespace/mount.go
@@ -21,7 +21,7 @@
// mountIntoMountTable mounts a single server into a single mount table.
func mountIntoMountTable(ctx *context.T, client ipc.Client, name, server string, ttl time.Duration, flags naming.MountFlag, id string) (s status) {
s.id = id
- ctx, _ = ctx.WithTimeout(callTimeout)
+ ctx, _ = context.WithTimeout(ctx, callTimeout)
call, err := client.StartCall(ctx, name, "Mount", []interface{}{server, uint32(ttl.Seconds()), flags}, options.NoResolve(true))
s.err = err
if err != nil {
@@ -36,7 +36,7 @@
// unmountFromMountTable removes a single mounted server from a single mount table.
func unmountFromMountTable(ctx *context.T, client ipc.Client, name, server string, id string) (s status) {
s.id = id
- ctx, _ = ctx.WithTimeout(callTimeout)
+ ctx, _ = context.WithTimeout(ctx, callTimeout)
call, err := client.StartCall(ctx, name, "Unmount", []interface{}{server}, options.NoResolve(true))
s.err = err
if err != nil {
diff --git a/runtimes/google/naming/namespace/resolve.go b/runtimes/google/naming/namespace/resolve.go
index 4deb9c2..c03f9c8 100644
--- a/runtimes/google/naming/namespace/resolve.go
+++ b/runtimes/google/naming/namespace/resolve.go
@@ -31,7 +31,7 @@
return &ne, nil
}
// Not in cache, call the real server.
- callCtx, _ := ctx.WithTimeout(callTimeout)
+ callCtx, _ := context.WithTimeout(ctx, callTimeout)
call, err := client.StartCall(callCtx, pattern_and_name, "ResolveStepX", nil, append(opts, options.NoResolve(true))...)
if err != nil {
finalErr = err
diff --git a/runtimes/google/rt/mgmt.go b/runtimes/google/rt/mgmt.go
index 1b9a4a2..4599eee 100644
--- a/runtimes/google/rt/mgmt.go
+++ b/runtimes/google/rt/mgmt.go
@@ -5,6 +5,7 @@
"time"
"v.io/core/veyron2"
+ "v.io/core/veyron2/context"
"v.io/core/veyron2/ipc"
"v.io/core/veyron2/mgmt"
"v.io/core/veyron2/naming"
@@ -78,7 +79,7 @@
}
func (rt *vrt) callbackToParent(parentName, myName string) error {
- ctx, _ := rt.NewContext().WithTimeout(10 * time.Second)
+ ctx, _ := context.WithTimeout(rt.NewContext(), 10*time.Second)
call, err := rt.Client().StartCall(ctx, parentName, "Set", []interface{}{mgmt.AppCycleManagerConfigKey, myName})
if err != nil {
return err
diff --git a/runtimes/google/vtrace/vtrace.go b/runtimes/google/vtrace/vtrace.go
index 84c2825..7493f56 100644
--- a/runtimes/google/vtrace/vtrace.go
+++ b/runtimes/google/vtrace/vtrace.go
@@ -81,7 +81,7 @@
if req.Method == vtrace.InMemory {
newSpan.collector.ForceCollect()
}
- return ctx.WithValue(spanKey{}, newSpan), newSpan
+ return context.WithValue(ctx, spanKey{}, newSpan), newSpan
}
func WithNewRootSpan(ctx *context.T, store *Store, forceCollect bool) (*context.T, vtrace.Span) {
@@ -95,14 +95,14 @@
}
s := newSpan(id, "", col)
- return ctx.WithValue(spanKey{}, s), s
+ return context.WithValue(ctx, spanKey{}, s), s
}
// NewSpan creates a new span.
func WithNewSpan(parent *context.T, name string) (*context.T, vtrace.Span) {
if curSpan := getSpan(parent); curSpan != nil {
s := newSpan(curSpan.ID(), name, curSpan.collector)
- return parent.WithValue(spanKey{}, s), s
+ return context.WithValue(parent, spanKey{}, s), s
}
vlog.Error("vtrace: Creating a new child span from context with no existing span.")
diff --git a/services/mgmt/build/impl/impl_test.go b/services/mgmt/build/impl/impl_test.go
index f7deaca..5f27b50 100644
--- a/services/mgmt/build/impl/impl_test.go
+++ b/services/mgmt/build/impl/impl_test.go
@@ -9,6 +9,7 @@
"testing"
"v.io/core/veyron2"
+ "v.io/core/veyron2/context"
"v.io/core/veyron2/rt"
"v.io/core/veyron2/services/mgmt/build"
@@ -76,7 +77,7 @@
func invokeBuild(t *testing.T, client build.BuilderClientMethods, files []build.File) ([]byte, []build.File, error) {
arch, opsys := getArch(), getOS()
- ctx, cancel := globalRT.NewContext().WithCancel()
+ ctx, cancel := context.WithCancel(globalRT.NewContext())
defer cancel()
stream, err := client.Build(ctx, arch, opsys)
if err != nil {
diff --git a/services/mgmt/debug/dispatcher_test.go b/services/mgmt/debug/dispatcher_test.go
index 2f93483..dac56ab 100644
--- a/services/mgmt/debug/dispatcher_test.go
+++ b/services/mgmt/debug/dispatcher_test.go
@@ -170,7 +170,7 @@
{
ns := runtime.Namespace()
ns.SetRoots(naming.JoinAddressName(endpoint, "debug"))
- ctx, cancel := runtime.NewContext().WithTimeout(10 * time.Second)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), 10*time.Second)
defer cancel()
c, err := ns.Glob(ctx, "logs/...")
if err != nil {
diff --git a/services/mgmt/device/impl/app_service.go b/services/mgmt/device/impl/app_service.go
index 740c859..3325199 100644
--- a/services/mgmt/device/impl/app_service.go
+++ b/services/mgmt/device/impl/app_service.go
@@ -382,7 +382,7 @@
if len(i.suffix) > 0 {
return "", verror2.Make(ErrInvalidSuffix, call.Context())
}
- ctx, cancel := call.Context().WithTimeout(ipcContextTimeout)
+ ctx, cancel := context.WithTimeout(call.Context(), ipcContextTimeout)
defer cancel()
envelope, err := fetchAppEnvelope(ctx, applicationVON)
if err != nil {
@@ -940,7 +940,7 @@
func stopAppRemotely(ctx *context.T, appVON string) error {
appStub := appcycle.AppCycleClient(appVON)
- ctx, cancel := ctx.WithTimeout(ipcContextTimeout)
+ ctx, cancel := context.WithTimeout(ctx, ipcContextTimeout)
defer cancel()
stream, err := appStub.Stop(ctx)
if err != nil {
@@ -1025,7 +1025,7 @@
if err != nil {
return err
}
- ctx, cancel := call.Context().WithTimeout(ipcContextTimeout)
+ ctx, cancel := context.WithTimeout(call.Context(), ipcContextTimeout)
defer cancel()
newEnvelope, err := fetchAppEnvelope(ctx, originVON)
if err != nil {
diff --git a/services/mgmt/device/impl/callback.go b/services/mgmt/device/impl/callback.go
index 174aec5..f785b61 100644
--- a/services/mgmt/device/impl/callback.go
+++ b/services/mgmt/device/impl/callback.go
@@ -22,7 +22,7 @@
return
}
client := device.ConfigClient(callbackName)
- ctx, cancel := ctx.WithTimeout(ipcContextTimeout)
+ ctx, cancel := context.WithTimeout(ctx, ipcContextTimeout)
defer cancel()
if err := client.Set(ctx, mgmt.ChildNameConfigKey, name); err != nil {
vlog.Fatalf("Set(%v, %v) failed: %v", mgmt.ChildNameConfigKey, name, err)
diff --git a/services/mgmt/device/impl/device_service.go b/services/mgmt/device/impl/device_service.go
index 08e9e86..458456b 100644
--- a/services/mgmt/device/impl/device_service.go
+++ b/services/mgmt/device/impl/device_service.go
@@ -425,7 +425,7 @@
}
func (s *deviceService) Update(call ipc.ServerContext) error {
- ctx, cancel := call.Context().WithTimeout(ipcContextTimeout)
+ ctx, cancel := context.WithTimeout(call.Context(), ipcContextTimeout)
defer cancel()
updatingState := s.updating
diff --git a/services/mgmt/device/impl/impl_test.go b/services/mgmt/device/impl/impl_test.go
index 84a5f69..b86cffe 100644
--- a/services/mgmt/device/impl/impl_test.go
+++ b/services/mgmt/device/impl/impl_test.go
@@ -253,7 +253,7 @@
}
func cat(name, file string) (string, error) {
- ctx, cancel := globalRT.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(globalRT.NewContext(), time.Minute)
defer cancel()
call, err := globalRT.Client().StartCall(ctx, name, "Cat", []interface{}{file})
if err != nil {
diff --git a/services/mgmt/lib/binary/impl.go b/services/mgmt/lib/binary/impl.go
index ea7f6ec..8b5472d 100644
--- a/services/mgmt/lib/binary/impl.go
+++ b/services/mgmt/lib/binary/impl.go
@@ -36,7 +36,7 @@
)
func Delete(ctx *context.T, name string) error {
- ctx, cancel := ctx.WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
if err := repository.BinaryClient(name).Delete(ctx); err != nil {
vlog.Errorf("Delete() failed: %v", err)
@@ -52,7 +52,7 @@
}
func downloadPartAttempt(ctx *context.T, w io.WriteSeeker, client repository.BinaryClientStub, ip *indexedPart) bool {
- ctx, cancel := ctx.WithCancel()
+ ctx, cancel := context.WithCancel(ctx)
defer cancel()
if _, err := w.Seek(ip.offset, 0); err != nil {
@@ -136,7 +136,7 @@
}
defer os.Remove(file.Name())
defer file.Close()
- ctx, cancel := ctx.WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
mediaInfo, err := download(ctx, file, von)
if err != nil {
@@ -158,7 +158,7 @@
return verror.Make(errOperationFailed, ctx)
}
defer file.Close()
- ctx, cancel := ctx.WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
mediaInfo, err := download(ctx, file, von)
if err != nil {
@@ -193,7 +193,7 @@
}
func DownloadURL(ctx *context.T, von string) (string, int64, error) {
- ctx, cancel := ctx.WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
url, ttl, err := repository.BinaryClient(von).DownloadURL(ctx)
if err != nil {
@@ -204,7 +204,7 @@
}
func uploadPartAttempt(ctx *context.T, r io.ReadSeeker, client repository.BinaryClientStub, part int, size int64) (bool, error) {
- ctx, cancel := ctx.WithCancel()
+ ctx, cancel := context.WithCancel(ctx)
defer cancel()
offset := int64(part * partSize)
@@ -306,7 +306,7 @@
func Upload(ctx *context.T, von string, data []byte, mediaInfo repository.MediaInfo) error {
buffer := bytes.NewReader(data)
- ctx, cancel := ctx.WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
return upload(ctx, buffer, mediaInfo, von)
}
@@ -318,7 +318,7 @@
vlog.Errorf("Open(%v) failed: %v", err)
return verror.Make(errOperationFailed, ctx)
}
- ctx, cancel := ctx.WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
mediaInfo := packages.MediaInfoForFileName(path)
return upload(ctx, file, mediaInfo, von)
diff --git a/services/mgmt/stats/impl/stats_test.go b/services/mgmt/stats/impl/stats_test.go
index 882cde4..489604c 100644
--- a/services/mgmt/stats/impl/stats_test.go
+++ b/services/mgmt/stats/impl/stats_test.go
@@ -7,6 +7,7 @@
"time"
"v.io/core/veyron2"
+ "v.io/core/veyron2/context"
"v.io/core/veyron2/naming"
"v.io/core/veyron2/rt"
"v.io/core/veyron2/security"
@@ -97,7 +98,7 @@
{
noRM := types.ResumeMarker{}
_ = noRM
- ctx, cancel := runtime.NewContext().WithCancel()
+ ctx, cancel := context.WithCancel(runtime.NewContext())
stream, err := c.WatchGlob(ctx, types.GlobRequest{Pattern: "testing/foo/bar"})
if err != nil {
t.Fatalf("c.WatchGlob failed: %v", err)
diff --git a/tools/application/impl.go b/tools/application/impl.go
index 2321350..3471add 100644
--- a/tools/application/impl.go
+++ b/tools/application/impl.go
@@ -66,7 +66,7 @@
}
name, profiles := args[0], args[1]
app := repository.ApplicationClient(name)
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
j, err := getEnvelopeJSON(ctx, app, profiles)
if err != nil {
@@ -98,7 +98,7 @@
if err != nil {
return fmt.Errorf("ReadFile(%v): %v", envelope, err)
}
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
if err = putEnvelopeJSON(ctx, app, profiles, j); err != nil {
return err
@@ -124,7 +124,7 @@
}
name, profile := args[0], args[1]
app := repository.ApplicationClient(name)
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
if err := app.Remove(ctx, profile); err != nil {
return err
@@ -158,7 +158,7 @@
f.Close()
defer os.Remove(fileName)
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
envData, err := getEnvelopeJSON(ctx, app, profile)
if err != nil {
diff --git a/tools/build/impl.go b/tools/build/impl.go
index 3df7bd0..2a91d30 100644
--- a/tools/build/impl.go
+++ b/tools/build/impl.go
@@ -139,7 +139,7 @@
binaries := make(chan vbuild.File)
go func() {
defer close(binaries)
- ctx, cancel := ctx.WithCancel()
+ ctx, cancel := context.WithCancel(ctx)
defer cancel()
client := vbuild.BuilderClient(name)
@@ -215,7 +215,7 @@
errchan := make(chan error)
defer close(errchan)
- ctx, ctxCancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, ctxCancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer ctxCancel()
// Start all stages of the pipeline.
diff --git a/tools/debug/impl.go b/tools/debug/impl.go
index 41f2461..7bdc1d3 100644
--- a/tools/debug/impl.go
+++ b/tools/debug/impl.go
@@ -190,7 +190,7 @@
func doGlob(ctx *context.T, pattern string, results chan<- naming.MountEntry, errors chan<- error, wg *sync.WaitGroup) {
defer wg.Done()
- ctx, cancel := ctx.WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
c, err := runtime.Namespace().Glob(ctx, pattern)
if err != nil {
@@ -319,7 +319,7 @@
func doValue(ctx *context.T, name string, output chan<- string, errors chan<- error, wg *sync.WaitGroup) {
defer wg.Done()
- ctx, cancel := ctx.WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
v, err := stats.StatsClient(name).Value(ctx)
if err != nil {
diff --git a/tools/mgmt/device/associate_impl.go b/tools/mgmt/device/associate_impl.go
index fdcdb38..81307e2 100644
--- a/tools/mgmt/device/associate_impl.go
+++ b/tools/mgmt/device/associate_impl.go
@@ -4,6 +4,7 @@
"fmt"
"time"
+ "v.io/core/veyron2/context"
"v.io/core/veyron2/services/mgmt/device"
"v.io/lib/cmdline"
)
@@ -23,7 +24,7 @@
return cmd.UsageErrorf("list: incorrect number of arguments, expected %d, got %d", expected, got)
}
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
assocs, err := device.DeviceClient(args[0]).ListAssociations(ctx)
if err != nil {
@@ -52,7 +53,7 @@
if expected, got := 3, len(args); got < expected {
return cmd.UsageErrorf("add: incorrect number of arguments, expected at least %d, got %d", expected, got)
}
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
return device.DeviceClient(args[0]).AssociateAccount(ctx, args[2:], args[1])
}
@@ -72,7 +73,7 @@
if expected, got := 2, len(args); got < expected {
return cmd.UsageErrorf("remove: incorrect number of arguments, expected at least %d, got %d", expected, got)
}
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
return device.DeviceClient(args[0]).AssociateAccount(ctx, args[1:], "")
}
diff --git a/tools/mounttable/impl.go b/tools/mounttable/impl.go
index a6f568c..0313315 100644
--- a/tools/mounttable/impl.go
+++ b/tools/mounttable/impl.go
@@ -5,6 +5,7 @@
"fmt"
"time"
+ "v.io/core/veyron2/context"
"v.io/core/veyron2/ipc"
"v.io/core/veyron2/naming"
"v.io/core/veyron2/options"
@@ -35,7 +36,7 @@
if expected, got := 2, len(args); expected != got {
return cmd.UsageErrorf("glob: incorrect number of arguments, expected %d, got %d", expected, got)
}
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
name, pattern := args[0], args[1]
call, err := runtime.Client().StartCall(ctx, name, ipc.GlobMethod, []interface{}{pattern}, options.NoResolve(true))
@@ -97,7 +98,7 @@
}
}
}
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
call, err := runtime.Client().StartCall(ctx, args[0], "Mount", []interface{}{args[1], seconds, 0}, options.NoResolve(true))
if err != nil {
@@ -130,7 +131,7 @@
if expected, got := 2, len(args); expected != got {
return cmd.UsageErrorf("unmount: incorrect number of arguments, expected %d, got %d", expected, got)
}
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
call, err := runtime.Client().StartCall(ctx, args[0], "Unmount", []interface{}{args[1]}, options.NoResolve(true))
if err != nil {
@@ -162,7 +163,7 @@
if expected, got := 1, len(args); expected != got {
return cmd.UsageErrorf("mount: incorrect number of arguments, expected %d, got %d", expected, got)
}
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
call, err := runtime.Client().StartCall(ctx, args[0], "ResolveStepX", []interface{}{}, options.NoResolve(true))
if err != nil {
diff --git a/tools/namespace/impl.go b/tools/namespace/impl.go
index d030bf2..d50e2c2 100644
--- a/tools/namespace/impl.go
+++ b/tools/namespace/impl.go
@@ -4,6 +4,7 @@
"fmt"
"time"
+ "v.io/core/veyron2/context"
"v.io/core/veyron2/naming"
"v.io/core/veyron2/vlog"
"v.io/lib/cmdline"
@@ -27,7 +28,7 @@
}
pattern := args[0]
ns := runtime.Namespace()
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
c, err := ns.Glob(ctx, pattern)
if err != nil {
@@ -75,7 +76,7 @@
return fmt.Errorf("TTL parse error: %v", err)
}
ns := runtime.Namespace()
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
if err = ns.Mount(ctx, name, server, ttl); err != nil {
vlog.Infof("ns.Mount(%q, %q, %s) failed: %v", name, server, ttl, err)
@@ -104,7 +105,7 @@
name := args[0]
server := args[1]
ns := runtime.Namespace()
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
if err := ns.Unmount(ctx, name, server); err != nil {
vlog.Infof("ns.Unmount(%q, %q) failed: %v", name, server, err)
@@ -129,7 +130,7 @@
}
name := args[0]
ns := runtime.Namespace()
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
servers, err := ns.Resolve(ctx, name)
if err != nil {
@@ -157,7 +158,7 @@
}
name := args[0]
ns := runtime.Namespace()
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
e, err := ns.ResolveToMountTableX(ctx, name)
if err != nil {
diff --git a/tools/principal/main.go b/tools/principal/main.go
index 14fb1b3..48da096 100644
--- a/tools/principal/main.go
+++ b/tools/principal/main.go
@@ -16,6 +16,7 @@
vsecurity "v.io/core/veyron/security"
"v.io/core/veyron/services/identity"
"v.io/core/veyron2"
+ "v.io/core/veyron2/context"
"v.io/core/veyron2/ipc"
"v.io/core/veyron2/naming"
"v.io/core/veyron2/rt"
@@ -600,7 +601,7 @@
}
macaroon := <-macaroonChan
service := <-macaroonChan
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
var reply security.WireBlessings
diff --git a/tools/profile/impl.go b/tools/profile/impl.go
index 6d2c1eb..1925450 100644
--- a/tools/profile/impl.go
+++ b/tools/profile/impl.go
@@ -6,6 +6,7 @@
"v.io/core/veyron/services/mgmt/profile"
"v.io/core/veyron/services/mgmt/repository"
+ "v.io/core/veyron2/context"
"v.io/core/veyron2/services/mgmt/build"
"v.io/lib/cmdline"
)
@@ -25,7 +26,7 @@
}
name := args[0]
p := repository.ProfileClient(name)
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
label, err := p.Label(ctx)
if err != nil {
@@ -50,7 +51,7 @@
}
name := args[0]
p := repository.ProfileClient(name)
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
desc, err := p.Description(ctx)
if err != nil {
@@ -75,7 +76,7 @@
}
name := args[0]
p := repository.ProfileClient(name)
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
spec, err := p.Specification(ctx)
if err != nil {
@@ -110,7 +111,7 @@
Label: "example",
OS: build.Linux,
}
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
if err := p.Put(ctx, spec); err != nil {
return err
@@ -134,7 +135,7 @@
}
name := args[0]
p := repository.ProfileClient(name)
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
if err := p.Remove(ctx); err != nil {
return err
diff --git a/tools/vrpc/impl.go b/tools/vrpc/impl.go
index 57695ba..041c189 100644
--- a/tools/vrpc/impl.go
+++ b/tools/vrpc/impl.go
@@ -57,7 +57,7 @@
}
defer client.Close()
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
signature, err := getSignature(ctx, cmd, args[0], client)
if err != nil {
@@ -95,7 +95,7 @@
}
defer client.Close()
- ctx, cancel := runtime.NewContext().WithTimeout(time.Minute)
+ ctx, cancel := context.WithTimeout(runtime.NewContext(), time.Minute)
defer cancel()
signature, err := getSignature(ctx, cmd, server, client)
if err != nil {