package relay
import (
"context"
"errors"
amhelp "github.com/pancsta/asyncmachine-go/pkg/helpers"
am "github.com/pancsta/asyncmachine-go/pkg/machine"
arpc "github.com/pancsta/asyncmachine-go/pkg/rpc"
ssrpc "github.com/pancsta/asyncmachine-go/pkg/rpc/states"
"github.com/pancsta/asyncmachine-go/tools/relay/types"
)
func (r *Relay ) startArpcToDbg (
ctx context .Context , e *am .Event , cmd *types .ArgsArpcToDbg ,
) {
r .out ("connecting to aRPC %s, telemetry to %s\n" , cmd .RpcAddr , cmd .DbgAddr )
client , err := arpc .NewClient (ctx , cmd .RpcAddr , "arpc-to-dbg" , nil ,
&arpc .ClientOpts {
Parent : r .Mach ,
DebugDisable : true ,
})
if err != nil {
r .Mach .EvAddErr (e , err , nil )
return
}
r .arpcClient = client
client .Start (nil )
r .Mach .Go (ctx , func () {
select {
case <- client .Mach .When1 (ssrpc .ClientStates .Ready , ctx ):
if client .Mach .Not1 (ssrpc .ClientStates .Ready ) {
return
}
case <- client .Mach .When1 (ssrpc .ClientStates .ConnRetryFailed , ctx ):
err := errors .New ("aRPC connection failed" )
r .Mach .EvAddErr (e , err , nil )
r .Mach .EvRemove1 (e , ssR .Start , nil )
return
case <- ctx .Done ():
return
}
if client .NetMach == nil {
r .Mach .EvAddErr (e , errors .New ("aRPC netmach missing" ), nil )
return
}
logLvl := am .LogOps
for _ , mach := range []am .Api {r .Mach , client .Mach , client .NetMach } {
if err := amhelp .MachDebug (mach , cmd .DbgAddr , logLvl , false ,
amhelp .SemConfigEnv (true )); err != nil {
r .Mach .EvAddErr (e , err , nil )
return
}
}
r .out ("connected, streaming telemetry to %s\n" , cmd .DbgAddr )
})
}
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .