Skip to content

Commit 71d4ee7

Browse files
committed
fix: refactor for changes to starpc
Signed-off-by: Christian Stewart <christian@aperture.us>
1 parent 7dd3b57 commit 71d4ee7

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/aperturerobotics/controllerbus v0.50.1 // latest
1010
github.com/aperturerobotics/entitygraph v0.11.0 // latest
1111
github.com/aperturerobotics/protobuf-go-lite v0.9.1 // latest
12-
github.com/aperturerobotics/starpc v0.38.1 // latest
12+
github.com/aperturerobotics/starpc v0.39.0 // latest
1313
github.com/aperturerobotics/util v1.30.0 // latest
1414
)
1515

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ github.com/aperturerobotics/protobuf-go-lite v0.9.1 h1:P1knXKnwLJpVE8fmeXYGckKu7
2828
github.com/aperturerobotics/protobuf-go-lite v0.9.1/go.mod h1:fULrxQxEBWKQm7vvju9AfjTp9yfHoLgwMQWTiZQ2tg0=
2929
github.com/aperturerobotics/quic-go v0.48.2-0.20241029082227-fa76c393ee89 h1:MUXLrLDjCw36dx8OeBwF/B7YP5akyoU6Ps+v50qR5Lo=
3030
github.com/aperturerobotics/quic-go v0.48.2-0.20241029082227-fa76c393ee89/go.mod h1:vhhkHYq2i9lb0bOllqKhOdtg/3i7r4o/7zc8XI/T4lo=
31-
github.com/aperturerobotics/starpc v0.38.1 h1:pdDfhrTn6nsEtn+/qYbFNgXRHnlJNb/MdbF9CMqgMoA=
32-
github.com/aperturerobotics/starpc v0.38.1/go.mod h1:IT2VZ+tDYFleXhcOSvxcUe1fyVk8rD6JCISwjFeA6OA=
31+
github.com/aperturerobotics/starpc v0.39.0 h1:n/NR16KdzulIZFTf6PYo53mFHti4vg+O65kgaBGEXh4=
32+
github.com/aperturerobotics/starpc v0.39.0/go.mod h1:GVNyIvtGf/VO/MpWLCPiGMT9GVBFcdruSivsgD4oKcE=
3333
github.com/aperturerobotics/util v1.30.0 h1:OKhFVPnAfR8/dfVNV27EtMr27C0kzwPiStoCwKiint0=
3434
github.com/aperturerobotics/util v1.30.0/go.mod h1:T97YTP+FVLegYo5rylOVaPuTLyZyiDqYxD5zVLI9YAc=
3535
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=

rpc/access/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func (s *AccessRpcServiceServer) LookupRpcService(
158158

159159
// CallRpcService looks up the rpc service with the request & invokes the RPC.
160160
func (s *AccessRpcServiceServer) CallRpcService(strm SRPCAccessRpcService_CallRpcServiceStream) error {
161-
return rpcstream.HandleRpcStream(strm, func(ctx context.Context, componentID string) (srpc.Invoker, func(), error) {
161+
return rpcstream.HandleRpcStream(strm, func(ctx context.Context, componentID string, released func()) (srpc.Invoker, func(), error) {
162162
// parse component id json
163163
req := &LookupRpcServiceRequest{}
164164
if err := req.UnmarshalComponentID(componentID); err != nil {
@@ -182,6 +182,7 @@ func (s *AccessRpcServiceServer) CallRpcService(strm SRPCAccessRpcService_CallRp
182182
req.GetServiceId(),
183183
serverID,
184184
s.waitOne,
185+
released,
185186
)
186187
if err != nil || invokerRef == nil {
187188
return nil, nil, err

rpc/invoker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func NewInvoker(b bus.Bus, serverID string, wait bool) *Invoker {
3434
func (i *Invoker) InvokeMethod(serviceID, methodID string, strm srpc.Stream) (bool, error) {
3535
ctx := strm.Context()
3636

37-
invokers, _, invokerRef, err := ExLookupRpcService(ctx, i.b, serviceID, i.serverID, i.wait)
37+
invokers, _, invokerRef, err := ExLookupRpcService(ctx, i.b, serviceID, i.serverID, i.wait, nil)
3838
if err != nil || invokerRef == nil {
3939
return false, err
4040
}

rpc/lookup-rpc-service.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,21 @@ func NewLookupRpcService(serviceID, serverID string) LookupRpcService {
5252
// If values are returned, returns vals, valsRef, nil
5353
// Otherwise returns nil, nil, err
5454
// If waitOne is set, waits for at least one value before returning.
55+
// valDisposeCb is called if any of the values are no longer valid.
56+
// valDisposeCb might be called multiple times.
5557
func ExLookupRpcService(
5658
ctx context.Context,
5759
b bus.Bus,
5860
serviceID, serverID string,
5961
waitOne bool,
62+
valDisposeCb func(),
6063
) ([]LookupRpcServiceValue, directive.Instance, directive.Reference, error) {
6164
out, di, valsRef, err := bus.ExecCollectValues[LookupRpcServiceValue](
6265
ctx,
6366
b,
6467
NewLookupRpcService(serviceID, serverID),
6568
waitOne,
66-
nil,
69+
valDisposeCb,
6770
)
6871
if err != nil {
6972
return nil, nil, nil, err

0 commit comments

Comments
 (0)