From 66a7a77278e35f9869f8e6699562545026c936f8 Mon Sep 17 00:00:00 2001 From: Louis Thibault Date: Fri, 5 Aug 2022 09:46:02 -0400 Subject: [PATCH 01/11] Add SetFlowLimiter method to interfaceClient template. --- capnpc-go/templates/interfaceClient | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/capnpc-go/templates/interfaceClient b/capnpc-go/templates/interfaceClient index aa39eec5..b44c8129 100644 --- a/capnpc-go/templates/interfaceClient +++ b/capnpc-go/templates/interfaceClient @@ -40,3 +40,11 @@ func ({{$.Node.Name}}) DecodeFromPtr(p capnp.Ptr) {{$.Node.Name}} { func (c {{$.Node.Name}}) IsValid() bool { return capnp.Client(c).IsValid() } + +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c {{$.Node.Name}}) SetFlowLimiter(lim flowcontrol.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} From 0f132a3a845a29cbf7a321802a5a2ad6cc15af4e Mon Sep 17 00:00:00 2001 From: Louis Thibault Date: Fri, 5 Aug 2022 09:48:54 -0400 Subject: [PATCH 02/11] Add docstring for IsValid method in interfaceClient template. --- capnpc-go/templates/interfaceClient | 3 +++ 1 file changed, 3 insertions(+) diff --git a/capnpc-go/templates/interfaceClient b/capnpc-go/templates/interfaceClient index b44c8129..873e0e8a 100644 --- a/capnpc-go/templates/interfaceClient +++ b/capnpc-go/templates/interfaceClient @@ -37,6 +37,9 @@ func ({{$.Node.Name}}) DecodeFromPtr(p capnp.Ptr) {{$.Node.Name}} { return {{$.Node.Name}}(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c {{$.Node.Name}}) IsValid() bool { return capnp.Client(c).IsValid() } From 8cafad8a102085b2782348352df6cdd0647ec577 Mon Sep 17 00:00:00 2001 From: Louis Thibault Date: Fri, 5 Aug 2022 09:49:52 -0400 Subject: [PATCH 03/11] Add docstrings for ref-counting methods in interfaceClient template. --- capnpc-go/templates/interfaceClient | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/capnpc-go/templates/interfaceClient b/capnpc-go/templates/interfaceClient index 873e0e8a..4cb6d091 100644 --- a/capnpc-go/templates/interfaceClient +++ b/capnpc-go/templates/interfaceClient @@ -21,10 +21,18 @@ func (c {{$.Node.Name}}) {{.Name|title}}(ctx {{$.G.Imports.Context}}.Context, pa } {{end}} +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c {{$.Node.Name}}) AddRef() {{$.Node.Name}} { return {{$.Node.Name}}(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c {{$.Node.Name}}) Release() { capnp.Client(c).Release() } From aeddad66271cbe0980bf38feb0c11948a25e67fd Mon Sep 17 00:00:00 2001 From: Louis Thibault Date: Fri, 5 Aug 2022 09:51:22 -0400 Subject: [PATCH 04/11] Add String method to interfaceClient template. --- capnpc-go/templates/interfaceClient | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/capnpc-go/templates/interfaceClient b/capnpc-go/templates/interfaceClient index 4cb6d091..b27849d4 100644 --- a/capnpc-go/templates/interfaceClient +++ b/capnpc-go/templates/interfaceClient @@ -21,6 +21,14 @@ func (c {{$.Node.Name}}) {{.Name|title}}(ctx {{$.G.Imports.Context}}.Context, pa } {{end}} +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c {{$.Node.Name}}) String() string { + return capnp.Client(c).String() +} + // AddRef creates a new Client that refers to the same capability as c. // If c is nil or has resolved to null, then AddRef returns nil. func (c {{$.Node.Name}}) AddRef() {{$.Node.Name}} { From 84c277a31c0a4a885dcf665beea16b421eba237d Mon Sep 17 00:00:00 2001 From: Louis Thibault Date: Fri, 5 Aug 2022 09:59:24 -0400 Subject: [PATCH 05/11] Add Resolve method to interfaceClient template. --- capnpc-go/templates/interfaceClient | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/capnpc-go/templates/interfaceClient b/capnpc-go/templates/interfaceClient index b27849d4..0ae489bb 100644 --- a/capnpc-go/templates/interfaceClient +++ b/capnpc-go/templates/interfaceClient @@ -45,6 +45,12 @@ func (c {{$.Node.Name}}) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c {{$.Node.Name}}) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c {{$.Node.Name}}) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } From 7040e45cd267dd4aa130f955b13341673c1b5987 Mon Sep 17 00:00:00 2001 From: Louis Thibault Date: Fri, 5 Aug 2022 16:51:39 -0400 Subject: [PATCH 06/11] Fix flowcontrol import. Regenerate schemas. --- capnpc-go/capnpc-go.go | 9 +- capnpc-go/fileparts.go | 5 ++ capnpc-go/templates/interfaceClient | 2 +- internal/aircraftlib/aircraft.capnp.go | 100 +++++++++++++++++++++++ rpc/internal/testcapnp/test.capnp.go | 100 +++++++++++++++++++++++ std/capnp/persistent/persistent.capnp.go | 34 ++++++++ 6 files changed, 245 insertions(+), 5 deletions(-) diff --git a/capnpc-go/capnpc-go.go b/capnpc-go/capnpc-go.go index 48de47d8..e2910197 100644 --- a/capnpc-go/capnpc-go.go +++ b/capnpc-go/capnpc-go.go @@ -30,10 +30,11 @@ import ( // Non-stdlib import paths. const ( - capnpImport = "capnproto.org/go/capnp/v3" - textImport = capnpImport + "/encoding/text" - schemasImport = capnpImport + "/schemas" - serverImport = capnpImport + "/server" + capnpImport = "capnproto.org/go/capnp/v3" + textImport = capnpImport + "/encoding/text" + schemasImport = capnpImport + "/schemas" + serverImport = capnpImport + "/server" + flowcontrolImport = capnpImport + "/flowcontrol" ) // genoptions are parameters that control code generation. diff --git a/capnpc-go/fileparts.go b/capnpc-go/fileparts.go index 3a8dcb81..0d38910e 100644 --- a/capnpc-go/fileparts.go +++ b/capnpc-go/fileparts.go @@ -67,6 +67,7 @@ func (i *imports) init() { i.reserve(importSpec{path: schemasImport, name: "schemas"}) i.reserve(importSpec{path: serverImport, name: "server"}) i.reserve(importSpec{path: textImport, name: "text"}) + i.reserve(importSpec{path: flowcontrolImport, name: "fc"}) i.reserve(importSpec{path: "context", name: "context"}) i.reserve(importSpec{path: "math", name: "math"}) @@ -89,6 +90,10 @@ func (i *imports) Text() string { return i.add(importSpec{path: textImport, name: "text"}) } +func (i *imports) FlowControl() string { + return i.add(importSpec{path: flowcontrolImport, name: "fc"}) +} + func (i *imports) Context() string { return i.add(importSpec{path: "context", name: "context"}) } diff --git a/capnpc-go/templates/interfaceClient b/capnpc-go/templates/interfaceClient index 0ae489bb..e43a724e 100644 --- a/capnpc-go/templates/interfaceClient +++ b/capnpc-go/templates/interfaceClient @@ -70,6 +70,6 @@ func (c {{$.Node.Name}}) IsValid() bool { // this client. This affects all future calls, but not calls already // waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, // which is also the default. -func (c {{$.Node.Name}}) SetFlowLimiter(lim flowcontrol.FlowLimiter) { +func (c {{$.Node.Name}}) SetFlowLimiter(lim {{.G.Imports.FlowControl}}.FlowLimiter) { capnp.Client(c).SetFlowLimiter(lim) } diff --git a/internal/aircraftlib/aircraft.capnp.go b/internal/aircraftlib/aircraft.capnp.go index 648893a2..0c7382a7 100644 --- a/internal/aircraftlib/aircraft.capnp.go +++ b/internal/aircraftlib/aircraft.capnp.go @@ -5,6 +5,7 @@ package aircraftlib import ( capnp "capnproto.org/go/capnp/v3" text "capnproto.org/go/capnp/v3/encoding/text" + fc "capnproto.org/go/capnp/v3/flowcontrol" schemas "capnproto.org/go/capnp/v3/schemas" server "capnproto.org/go/capnp/v3/server" context "context" @@ -5125,14 +5126,36 @@ func (c Echo) Echo(ctx context.Context, params func(Echo_echo_Params) error) (Ec return Echo_echo_Results_Future{Future: ans.Future()}, release } +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c Echo) String() string { + return capnp.Client(c).String() +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c Echo) AddRef() Echo { return Echo(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c Echo) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c Echo) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c Echo) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -5141,10 +5164,21 @@ func (Echo) DecodeFromPtr(p capnp.Ptr) Echo { return Echo(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c Echo) IsValid() bool { return capnp.Client(c).IsValid() } +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c Echo) SetFlowLimiter(lim fc.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + // A Echo_Server is a Echo with a local implementation. type Echo_Server interface { Echo(context.Context, Echo_echo) error @@ -5870,14 +5904,36 @@ func (c CallSequence) GetNumber(ctx context.Context, params func(CallSequence_ge return CallSequence_getNumber_Results_Future{Future: ans.Future()}, release } +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c CallSequence) String() string { + return capnp.Client(c).String() +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c CallSequence) AddRef() CallSequence { return CallSequence(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c CallSequence) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c CallSequence) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c CallSequence) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -5886,10 +5942,21 @@ func (CallSequence) DecodeFromPtr(p capnp.Ptr) CallSequence { return CallSequence(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c CallSequence) IsValid() bool { return capnp.Client(c).IsValid() } +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c CallSequence) SetFlowLimiter(lim fc.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + // A CallSequence_Server is a CallSequence with a local implementation. type CallSequence_Server interface { GetNumber(context.Context, CallSequence_getNumber) error @@ -6130,14 +6197,36 @@ func (c Pipeliner) GetNumber(ctx context.Context, params func(CallSequence_getNu return CallSequence_getNumber_Results_Future{Future: ans.Future()}, release } +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c Pipeliner) String() string { + return capnp.Client(c).String() +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c Pipeliner) AddRef() Pipeliner { return Pipeliner(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c Pipeliner) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c Pipeliner) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c Pipeliner) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -6146,10 +6235,21 @@ func (Pipeliner) DecodeFromPtr(p capnp.Ptr) Pipeliner { return Pipeliner(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c Pipeliner) IsValid() bool { return capnp.Client(c).IsValid() } +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c Pipeliner) SetFlowLimiter(lim fc.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + // A Pipeliner_Server is a Pipeliner with a local implementation. type Pipeliner_Server interface { NewPipeliner(context.Context, Pipeliner_newPipeliner) error diff --git a/rpc/internal/testcapnp/test.capnp.go b/rpc/internal/testcapnp/test.capnp.go index d4aa6b12..6e34feeb 100644 --- a/rpc/internal/testcapnp/test.capnp.go +++ b/rpc/internal/testcapnp/test.capnp.go @@ -5,6 +5,7 @@ package testcapnp import ( capnp "capnproto.org/go/capnp/v3" text "capnproto.org/go/capnp/v3/encoding/text" + fc "capnproto.org/go/capnp/v3/flowcontrol" schemas "capnproto.org/go/capnp/v3/schemas" server "capnproto.org/go/capnp/v3/server" stream "capnproto.org/go/capnp/v3/std/capnp/stream" @@ -33,14 +34,36 @@ func (c PingPong) EchoNum(ctx context.Context, params func(PingPong_echoNum_Para return PingPong_echoNum_Results_Future{Future: ans.Future()}, release } +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c PingPong) String() string { + return capnp.Client(c).String() +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c PingPong) AddRef() PingPong { return PingPong(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c PingPong) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c PingPong) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c PingPong) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -49,10 +72,21 @@ func (PingPong) DecodeFromPtr(p capnp.Ptr) PingPong { return PingPong(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c PingPong) IsValid() bool { return capnp.Client(c).IsValid() } +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c PingPong) SetFlowLimiter(lim fc.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + // A PingPong_Server is a PingPong with a local implementation. type PingPong_Server interface { EchoNum(context.Context, PingPong_echoNum) error @@ -284,14 +318,36 @@ func (c StreamTest) Push(ctx context.Context, params func(StreamTest_push_Params return stream.StreamResult_Future{Future: ans.Future()}, release } +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c StreamTest) String() string { + return capnp.Client(c).String() +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c StreamTest) AddRef() StreamTest { return StreamTest(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c StreamTest) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c StreamTest) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c StreamTest) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -300,10 +356,21 @@ func (StreamTest) DecodeFromPtr(p capnp.Ptr) StreamTest { return StreamTest(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c StreamTest) IsValid() bool { return capnp.Client(c).IsValid() } +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c StreamTest) SetFlowLimiter(lim fc.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + // A StreamTest_Server is a StreamTest with a local implementation. type StreamTest_Server interface { Push(context.Context, StreamTest_push) error @@ -484,14 +551,36 @@ func (c CapArgsTest) Self(ctx context.Context, params func(CapArgsTest_self_Para return CapArgsTest_self_Results_Future{Future: ans.Future()}, release } +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c CapArgsTest) String() string { + return capnp.Client(c).String() +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c CapArgsTest) AddRef() CapArgsTest { return CapArgsTest(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c CapArgsTest) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c CapArgsTest) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c CapArgsTest) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -500,10 +589,21 @@ func (CapArgsTest) DecodeFromPtr(p capnp.Ptr) CapArgsTest { return CapArgsTest(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c CapArgsTest) IsValid() bool { return capnp.Client(c).IsValid() } +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c CapArgsTest) SetFlowLimiter(lim fc.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + // A CapArgsTest_Server is a CapArgsTest with a local implementation. type CapArgsTest_Server interface { Call(context.Context, CapArgsTest_call) error diff --git a/std/capnp/persistent/persistent.capnp.go b/std/capnp/persistent/persistent.capnp.go index daabe9ad..bdfd4f95 100644 --- a/std/capnp/persistent/persistent.capnp.go +++ b/std/capnp/persistent/persistent.capnp.go @@ -5,6 +5,7 @@ package persistent import ( capnp "capnproto.org/go/capnp/v3" text "capnproto.org/go/capnp/v3/encoding/text" + fc "capnproto.org/go/capnp/v3/flowcontrol" schemas "capnproto.org/go/capnp/v3/schemas" server "capnproto.org/go/capnp/v3/server" context "context" @@ -34,14 +35,36 @@ func (c Persistent) Save(ctx context.Context, params func(Persistent_SaveParams) return Persistent_SaveResults_Future{Future: ans.Future()}, release } +// String returns a string that identifies this capability for debugging +// purposes. Its format should not be depended on: in particular, it +// should not be used to compare clients. Use IsSame to compare clients +// for equality. +func (c Persistent) String() string { + return capnp.Client(c).String() +} + +// AddRef creates a new Client that refers to the same capability as c. +// If c is nil or has resolved to null, then AddRef returns nil. func (c Persistent) AddRef() Persistent { return Persistent(capnp.Client(c).AddRef()) } +// Release releases a capability reference. If this is the last +// reference to the capability, then the underlying resources associated +// with the capability will be released. +// +// Release will panic if c has already been released, but not if c is +// nil or resolved to null. func (c Persistent) Release() { capnp.Client(c).Release() } +// Resolve blocks until the capability is fully resolved or the Context +// expires. +func (c Persistent) Resolve(ctx context.Context) error { + return capnp.Client(c).Resolve(ctx) +} + func (c Persistent) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr { return capnp.Client(c).EncodeAsPtr(seg) } @@ -50,10 +73,21 @@ func (Persistent) DecodeFromPtr(p capnp.Ptr) Persistent { return Persistent(capnp.Client{}.DecodeFromPtr(p)) } +// IsValid reports whether c is a valid reference to a capability. +// A reference is invalid if it is nil, has resolved to null, or has +// been released. func (c Persistent) IsValid() bool { return capnp.Client(c).IsValid() } +// Update the flowcontrol.FlowLimiter used to manage flow control for +// this client. This affects all future calls, but not calls already +// waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, +// which is also the default. +func (c Persistent) SetFlowLimiter(lim fc.FlowLimiter) { + capnp.Client(c).SetFlowLimiter(lim) +} + // A Persistent_Server is a Persistent with a local implementation. type Persistent_Server interface { Save(context.Context, Persistent_save) error From 03e6b0c6d09079e8a43acda22699f5f6b7b0c4bb Mon Sep 17 00:00:00 2001 From: Louis Thibault Date: Fri, 5 Aug 2022 16:55:14 -0400 Subject: [PATCH 07/11] Print capability type in String() method. --- capnpc-go/templates/interfaceClient | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/capnpc-go/templates/interfaceClient b/capnpc-go/templates/interfaceClient index e43a724e..2240cded 100644 --- a/capnpc-go/templates/interfaceClient +++ b/capnpc-go/templates/interfaceClient @@ -26,7 +26,7 @@ func (c {{$.Node.Name}}) {{.Name|title}}(ctx {{$.G.Imports.Context}}.Context, pa // should not be used to compare clients. Use IsSame to compare clients // for equality. func (c {{$.Node.Name}}) String() string { - return capnp.Client(c).String() + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) } // AddRef creates a new Client that refers to the same capability as c. From f5b6d96237951cd8fdda737a8c6a5d6ee4597973 Mon Sep 17 00:00:00 2001 From: Louis Thibault Date: Fri, 5 Aug 2022 16:57:39 -0400 Subject: [PATCH 08/11] Add IsSame method to interfaceClient template. --- capnpc-go/templates/interfaceClient | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/capnpc-go/templates/interfaceClient b/capnpc-go/templates/interfaceClient index 2240cded..17346ff1 100644 --- a/capnpc-go/templates/interfaceClient +++ b/capnpc-go/templates/interfaceClient @@ -66,6 +66,14 @@ func (c {{$.Node.Name}}) IsValid() bool { return capnp.Client(c).IsValid() } +// IsSame reports whether c and c2 refer to a capability created by the +// same call to NewClient. This can return false negatives if c or c2 +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c {{$.Node.Name}}) IsSame(other {{$.Node.Name}}) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + // Update the flowcontrol.FlowLimiter used to manage flow control for // this client. This affects all future calls, but not calls already // waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, From 4c15fd3969d1a27a09c3ddd112522e15e6f03736 Mon Sep 17 00:00:00 2001 From: Louis Thibault Date: Fri, 5 Aug 2022 17:01:11 -0400 Subject: [PATCH 09/11] Fix fmt import. Regenerate schemas. --- capnpc-go/fileparts.go | 5 ++++ capnpc-go/templates/interfaceClient | 2 +- internal/aircraftlib/aircraft.capnp.go | 31 +++++++++++++++++++++--- rpc/internal/testcapnp/test.capnp.go | 31 +++++++++++++++++++++--- std/capnp/persistent/persistent.capnp.go | 11 ++++++++- 5 files changed, 72 insertions(+), 8 deletions(-) diff --git a/capnpc-go/fileparts.go b/capnpc-go/fileparts.go index 0d38910e..f83a9759 100644 --- a/capnpc-go/fileparts.go +++ b/capnpc-go/fileparts.go @@ -69,6 +69,7 @@ func (i *imports) init() { i.reserve(importSpec{path: textImport, name: "text"}) i.reserve(importSpec{path: flowcontrolImport, name: "fc"}) + i.reserve(importSpec{path: "fmt", name: "fmt"}) i.reserve(importSpec{path: "context", name: "context"}) i.reserve(importSpec{path: "math", name: "math"}) i.reserve(importSpec{path: "strconv", name: "strconv"}) @@ -94,6 +95,10 @@ func (i *imports) FlowControl() string { return i.add(importSpec{path: flowcontrolImport, name: "fc"}) } +func (i *imports) Fmt() string { + return i.add(importSpec{path: "fmt", name: "fmt"}) +} + func (i *imports) Context() string { return i.add(importSpec{path: "context", name: "context"}) } diff --git a/capnpc-go/templates/interfaceClient b/capnpc-go/templates/interfaceClient index 17346ff1..432170d7 100644 --- a/capnpc-go/templates/interfaceClient +++ b/capnpc-go/templates/interfaceClient @@ -26,7 +26,7 @@ func (c {{$.Node.Name}}) {{.Name|title}}(ctx {{$.G.Imports.Context}}.Context, pa // should not be used to compare clients. Use IsSame to compare clients // for equality. func (c {{$.Node.Name}}) String() string { - return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) + return {{$.G.Imports.Fmt}}.Sprintf("%T(%v)", c, capnp.Client(c)) } // AddRef creates a new Client that refers to the same capability as c. diff --git a/internal/aircraftlib/aircraft.capnp.go b/internal/aircraftlib/aircraft.capnp.go index 0c7382a7..cddc7d2a 100644 --- a/internal/aircraftlib/aircraft.capnp.go +++ b/internal/aircraftlib/aircraft.capnp.go @@ -9,6 +9,7 @@ import ( schemas "capnproto.org/go/capnp/v3/schemas" server "capnproto.org/go/capnp/v3/server" context "context" + fmt "fmt" math "math" strconv "strconv" ) @@ -5131,7 +5132,7 @@ func (c Echo) Echo(ctx context.Context, params func(Echo_echo_Params) error) (Ec // should not be used to compare clients. Use IsSame to compare clients // for equality. func (c Echo) String() string { - return capnp.Client(c).String() + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) } // AddRef creates a new Client that refers to the same capability as c. @@ -5171,6 +5172,14 @@ func (c Echo) IsValid() bool { return capnp.Client(c).IsValid() } +// IsSame reports whether c and c2 refer to a capability created by the +// same call to NewClient. This can return false negatives if c or c2 +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c Echo) IsSame(other Echo) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + // Update the flowcontrol.FlowLimiter used to manage flow control for // this client. This affects all future calls, but not calls already // waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, @@ -5909,7 +5918,7 @@ func (c CallSequence) GetNumber(ctx context.Context, params func(CallSequence_ge // should not be used to compare clients. Use IsSame to compare clients // for equality. func (c CallSequence) String() string { - return capnp.Client(c).String() + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) } // AddRef creates a new Client that refers to the same capability as c. @@ -5949,6 +5958,14 @@ func (c CallSequence) IsValid() bool { return capnp.Client(c).IsValid() } +// IsSame reports whether c and c2 refer to a capability created by the +// same call to NewClient. This can return false negatives if c or c2 +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c CallSequence) IsSame(other CallSequence) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + // Update the flowcontrol.FlowLimiter used to manage flow control for // this client. This affects all future calls, but not calls already // waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, @@ -6202,7 +6219,7 @@ func (c Pipeliner) GetNumber(ctx context.Context, params func(CallSequence_getNu // should not be used to compare clients. Use IsSame to compare clients // for equality. func (c Pipeliner) String() string { - return capnp.Client(c).String() + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) } // AddRef creates a new Client that refers to the same capability as c. @@ -6242,6 +6259,14 @@ func (c Pipeliner) IsValid() bool { return capnp.Client(c).IsValid() } +// IsSame reports whether c and c2 refer to a capability created by the +// same call to NewClient. This can return false negatives if c or c2 +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c Pipeliner) IsSame(other Pipeliner) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + // Update the flowcontrol.FlowLimiter used to manage flow control for // this client. This affects all future calls, but not calls already // waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, diff --git a/rpc/internal/testcapnp/test.capnp.go b/rpc/internal/testcapnp/test.capnp.go index 6e34feeb..ecef4417 100644 --- a/rpc/internal/testcapnp/test.capnp.go +++ b/rpc/internal/testcapnp/test.capnp.go @@ -10,6 +10,7 @@ import ( server "capnproto.org/go/capnp/v3/server" stream "capnproto.org/go/capnp/v3/std/capnp/stream" context "context" + fmt "fmt" ) type PingPong capnp.Client @@ -39,7 +40,7 @@ func (c PingPong) EchoNum(ctx context.Context, params func(PingPong_echoNum_Para // should not be used to compare clients. Use IsSame to compare clients // for equality. func (c PingPong) String() string { - return capnp.Client(c).String() + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) } // AddRef creates a new Client that refers to the same capability as c. @@ -79,6 +80,14 @@ func (c PingPong) IsValid() bool { return capnp.Client(c).IsValid() } +// IsSame reports whether c and c2 refer to a capability created by the +// same call to NewClient. This can return false negatives if c or c2 +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c PingPong) IsSame(other PingPong) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + // Update the flowcontrol.FlowLimiter used to manage flow control for // this client. This affects all future calls, but not calls already // waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, @@ -323,7 +332,7 @@ func (c StreamTest) Push(ctx context.Context, params func(StreamTest_push_Params // should not be used to compare clients. Use IsSame to compare clients // for equality. func (c StreamTest) String() string { - return capnp.Client(c).String() + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) } // AddRef creates a new Client that refers to the same capability as c. @@ -363,6 +372,14 @@ func (c StreamTest) IsValid() bool { return capnp.Client(c).IsValid() } +// IsSame reports whether c and c2 refer to a capability created by the +// same call to NewClient. This can return false negatives if c or c2 +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c StreamTest) IsSame(other StreamTest) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + // Update the flowcontrol.FlowLimiter used to manage flow control for // this client. This affects all future calls, but not calls already // waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, @@ -556,7 +573,7 @@ func (c CapArgsTest) Self(ctx context.Context, params func(CapArgsTest_self_Para // should not be used to compare clients. Use IsSame to compare clients // for equality. func (c CapArgsTest) String() string { - return capnp.Client(c).String() + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) } // AddRef creates a new Client that refers to the same capability as c. @@ -596,6 +613,14 @@ func (c CapArgsTest) IsValid() bool { return capnp.Client(c).IsValid() } +// IsSame reports whether c and c2 refer to a capability created by the +// same call to NewClient. This can return false negatives if c or c2 +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c CapArgsTest) IsSame(other CapArgsTest) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + // Update the flowcontrol.FlowLimiter used to manage flow control for // this client. This affects all future calls, but not calls already // waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, diff --git a/std/capnp/persistent/persistent.capnp.go b/std/capnp/persistent/persistent.capnp.go index bdfd4f95..3ce458d2 100644 --- a/std/capnp/persistent/persistent.capnp.go +++ b/std/capnp/persistent/persistent.capnp.go @@ -9,6 +9,7 @@ import ( schemas "capnproto.org/go/capnp/v3/schemas" server "capnproto.org/go/capnp/v3/server" context "context" + fmt "fmt" ) const PersistentAnnotation = uint64(0xf622595091cafb67) @@ -40,7 +41,7 @@ func (c Persistent) Save(ctx context.Context, params func(Persistent_SaveParams) // should not be used to compare clients. Use IsSame to compare clients // for equality. func (c Persistent) String() string { - return capnp.Client(c).String() + return fmt.Sprintf("%T(%v)", c, capnp.Client(c)) } // AddRef creates a new Client that refers to the same capability as c. @@ -80,6 +81,14 @@ func (c Persistent) IsValid() bool { return capnp.Client(c).IsValid() } +// IsSame reports whether c and c2 refer to a capability created by the +// same call to NewClient. This can return false negatives if c or c2 +// are not fully resolved: use Resolve if this is an issue. If either +// c or other are released, then IsSame panics. +func (c Persistent) IsSame(other Persistent) bool { + return capnp.Client(c).IsSame(capnp.Client(other)) +} + // Update the flowcontrol.FlowLimiter used to manage flow control for // this client. This affects all future calls, but not calls already // waiting to send. Passing nil sets the value to flowcontrol.NopLimiter, From 1adb0c31e60ec0c5533dee143eaa33a0cae0742e Mon Sep 17 00:00:00 2001 From: Louis Thibault Date: Fri, 5 Aug 2022 17:33:11 -0400 Subject: [PATCH 10/11] Update remaining references to c2 in IsSame's docstring. --- capnpc-go/templates/interfaceClient | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/capnpc-go/templates/interfaceClient b/capnpc-go/templates/interfaceClient index 432170d7..60ea39ba 100644 --- a/capnpc-go/templates/interfaceClient +++ b/capnpc-go/templates/interfaceClient @@ -66,8 +66,8 @@ func (c {{$.Node.Name}}) IsValid() bool { return capnp.Client(c).IsValid() } -// IsSame reports whether c and c2 refer to a capability created by the -// same call to NewClient. This can return false negatives if c or c2 +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other // are not fully resolved: use Resolve if this is an issue. If either // c or other are released, then IsSame panics. func (c {{$.Node.Name}}) IsSame(other {{$.Node.Name}}) bool { From eed93fb6ebaa0e657fc27d2836a1fd80a9ba5eed Mon Sep 17 00:00:00 2001 From: Louis Thibault Date: Fri, 5 Aug 2022 19:53:23 -0400 Subject: [PATCH 11/11] Add GetFlowLimiter method to interfaceClient template. --- capnpc-go/templates/interfaceClient | 6 +++++ internal/aircraftlib/aircraft.capnp.go | 30 +++++++++++++++++------- rpc/internal/testcapnp/test.capnp.go | 30 +++++++++++++++++------- std/capnp/persistent/persistent.capnp.go | 10 +++++--- 4 files changed, 55 insertions(+), 21 deletions(-) diff --git a/capnpc-go/templates/interfaceClient b/capnpc-go/templates/interfaceClient index 60ea39ba..8d419958 100644 --- a/capnpc-go/templates/interfaceClient +++ b/capnpc-go/templates/interfaceClient @@ -81,3 +81,9 @@ func (c {{$.Node.Name}}) IsSame(other {{$.Node.Name}}) bool { func (c {{$.Node.Name}}) SetFlowLimiter(lim {{.G.Imports.FlowControl}}.FlowLimiter) { capnp.Client(c).SetFlowLimiter(lim) } + +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c {{$.Node.Name}}) GetFlowLimiter() {{.G.Imports.FlowControl}}.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} \ No newline at end of file diff --git a/internal/aircraftlib/aircraft.capnp.go b/internal/aircraftlib/aircraft.capnp.go index cddc7d2a..8492494c 100644 --- a/internal/aircraftlib/aircraft.capnp.go +++ b/internal/aircraftlib/aircraft.capnp.go @@ -5172,8 +5172,8 @@ func (c Echo) IsValid() bool { return capnp.Client(c).IsValid() } -// IsSame reports whether c and c2 refer to a capability created by the -// same call to NewClient. This can return false negatives if c or c2 +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other // are not fully resolved: use Resolve if this is an issue. If either // c or other are released, then IsSame panics. func (c Echo) IsSame(other Echo) bool { @@ -5188,7 +5188,11 @@ func (c Echo) SetFlowLimiter(lim fc.FlowLimiter) { capnp.Client(c).SetFlowLimiter(lim) } -// A Echo_Server is a Echo with a local implementation. +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c Echo) GetFlowLimiter() fc.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} // A Echo_Server is a Echo with a local implementation. type Echo_Server interface { Echo(context.Context, Echo_echo) error } @@ -5958,8 +5962,8 @@ func (c CallSequence) IsValid() bool { return capnp.Client(c).IsValid() } -// IsSame reports whether c and c2 refer to a capability created by the -// same call to NewClient. This can return false negatives if c or c2 +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other // are not fully resolved: use Resolve if this is an issue. If either // c or other are released, then IsSame panics. func (c CallSequence) IsSame(other CallSequence) bool { @@ -5974,7 +5978,11 @@ func (c CallSequence) SetFlowLimiter(lim fc.FlowLimiter) { capnp.Client(c).SetFlowLimiter(lim) } -// A CallSequence_Server is a CallSequence with a local implementation. +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c CallSequence) GetFlowLimiter() fc.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} // A CallSequence_Server is a CallSequence with a local implementation. type CallSequence_Server interface { GetNumber(context.Context, CallSequence_getNumber) error } @@ -6259,8 +6267,8 @@ func (c Pipeliner) IsValid() bool { return capnp.Client(c).IsValid() } -// IsSame reports whether c and c2 refer to a capability created by the -// same call to NewClient. This can return false negatives if c or c2 +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other // are not fully resolved: use Resolve if this is an issue. If either // c or other are released, then IsSame panics. func (c Pipeliner) IsSame(other Pipeliner) bool { @@ -6275,7 +6283,11 @@ func (c Pipeliner) SetFlowLimiter(lim fc.FlowLimiter) { capnp.Client(c).SetFlowLimiter(lim) } -// A Pipeliner_Server is a Pipeliner with a local implementation. +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c Pipeliner) GetFlowLimiter() fc.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} // A Pipeliner_Server is a Pipeliner with a local implementation. type Pipeliner_Server interface { NewPipeliner(context.Context, Pipeliner_newPipeliner) error diff --git a/rpc/internal/testcapnp/test.capnp.go b/rpc/internal/testcapnp/test.capnp.go index ecef4417..665dc5c9 100644 --- a/rpc/internal/testcapnp/test.capnp.go +++ b/rpc/internal/testcapnp/test.capnp.go @@ -80,8 +80,8 @@ func (c PingPong) IsValid() bool { return capnp.Client(c).IsValid() } -// IsSame reports whether c and c2 refer to a capability created by the -// same call to NewClient. This can return false negatives if c or c2 +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other // are not fully resolved: use Resolve if this is an issue. If either // c or other are released, then IsSame panics. func (c PingPong) IsSame(other PingPong) bool { @@ -96,7 +96,11 @@ func (c PingPong) SetFlowLimiter(lim fc.FlowLimiter) { capnp.Client(c).SetFlowLimiter(lim) } -// A PingPong_Server is a PingPong with a local implementation. +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c PingPong) GetFlowLimiter() fc.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} // A PingPong_Server is a PingPong with a local implementation. type PingPong_Server interface { EchoNum(context.Context, PingPong_echoNum) error } @@ -372,8 +376,8 @@ func (c StreamTest) IsValid() bool { return capnp.Client(c).IsValid() } -// IsSame reports whether c and c2 refer to a capability created by the -// same call to NewClient. This can return false negatives if c or c2 +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other // are not fully resolved: use Resolve if this is an issue. If either // c or other are released, then IsSame panics. func (c StreamTest) IsSame(other StreamTest) bool { @@ -388,7 +392,11 @@ func (c StreamTest) SetFlowLimiter(lim fc.FlowLimiter) { capnp.Client(c).SetFlowLimiter(lim) } -// A StreamTest_Server is a StreamTest with a local implementation. +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c StreamTest) GetFlowLimiter() fc.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} // A StreamTest_Server is a StreamTest with a local implementation. type StreamTest_Server interface { Push(context.Context, StreamTest_push) error } @@ -613,8 +621,8 @@ func (c CapArgsTest) IsValid() bool { return capnp.Client(c).IsValid() } -// IsSame reports whether c and c2 refer to a capability created by the -// same call to NewClient. This can return false negatives if c or c2 +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other // are not fully resolved: use Resolve if this is an issue. If either // c or other are released, then IsSame panics. func (c CapArgsTest) IsSame(other CapArgsTest) bool { @@ -629,7 +637,11 @@ func (c CapArgsTest) SetFlowLimiter(lim fc.FlowLimiter) { capnp.Client(c).SetFlowLimiter(lim) } -// A CapArgsTest_Server is a CapArgsTest with a local implementation. +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c CapArgsTest) GetFlowLimiter() fc.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} // A CapArgsTest_Server is a CapArgsTest with a local implementation. type CapArgsTest_Server interface { Call(context.Context, CapArgsTest_call) error diff --git a/std/capnp/persistent/persistent.capnp.go b/std/capnp/persistent/persistent.capnp.go index 3ce458d2..59468ab3 100644 --- a/std/capnp/persistent/persistent.capnp.go +++ b/std/capnp/persistent/persistent.capnp.go @@ -81,8 +81,8 @@ func (c Persistent) IsValid() bool { return capnp.Client(c).IsValid() } -// IsSame reports whether c and c2 refer to a capability created by the -// same call to NewClient. This can return false negatives if c or c2 +// IsSame reports whether c and other refer to a capability created by the +// same call to NewClient. This can return false negatives if c or other // are not fully resolved: use Resolve if this is an issue. If either // c or other are released, then IsSame panics. func (c Persistent) IsSame(other Persistent) bool { @@ -97,7 +97,11 @@ func (c Persistent) SetFlowLimiter(lim fc.FlowLimiter) { capnp.Client(c).SetFlowLimiter(lim) } -// A Persistent_Server is a Persistent with a local implementation. +// Get the current flowcontrol.FlowLimiter used to manage flow control +// for this client. +func (c Persistent) GetFlowLimiter() fc.FlowLimiter { + return capnp.Client(c).GetFlowLimiter() +} // A Persistent_Server is a Persistent with a local implementation. type Persistent_Server interface { Save(context.Context, Persistent_save) error }