mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-09 09:35:03 +09:00
Add error handling for ns/pp clients
This commit is contained in:
parent
1e1ce475f9
commit
c015841853
2 changed files with 16 additions and 0 deletions
|
@ -2,6 +2,7 @@ package nameserviceclient
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
|
@ -60,6 +61,11 @@ func New() AnyNsClientService {
|
|||
}
|
||||
|
||||
func (s *service) doClient(ctx context.Context, fn func(cl nsp.DRPCAnynsClient) error) error {
|
||||
if len(s.nodeconf.NamingNodePeers()) == 0 {
|
||||
log.Error("no namingNode peers configured")
|
||||
return errors.New("no namingNode peers configured")
|
||||
}
|
||||
|
||||
// it will try to connect to the Naming Node
|
||||
// please enable "namingNode" type of node in the config (in the network.nodes array)
|
||||
peer, err := s.pool.Get(ctx, s.nodeconf.NamingNodePeers()[0])
|
||||
|
|
|
@ -2,8 +2,10 @@ package paymentserviceclient
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/anyproto/any-sync/app"
|
||||
"github.com/anyproto/any-sync/app/logger"
|
||||
"github.com/anyproto/any-sync/net/pool"
|
||||
"github.com/anyproto/any-sync/net/rpc/rpcerr"
|
||||
"github.com/anyproto/any-sync/nodeconf"
|
||||
|
@ -13,6 +15,8 @@ import (
|
|||
|
||||
const CName = "any-pp.drpcclient"
|
||||
|
||||
var log = logger.NewNamed(CName)
|
||||
|
||||
/*
|
||||
* This client component can be used to access the Any Payment Processing node
|
||||
* from other components.
|
||||
|
@ -45,6 +49,12 @@ func New() AnyPpClientService {
|
|||
}
|
||||
|
||||
func (s *service) doClient(ctx context.Context, fn func(cl pp.DRPCAnyPaymentProcessingClient) error) error {
|
||||
if len(s.nodeconf.PaymentProcessingNodePeers()) == 0 {
|
||||
log.Error("no payment processing peers configured")
|
||||
|
||||
return errors.New("no paymentProcessingNode peers configured")
|
||||
}
|
||||
|
||||
// it will try to connect to the Payment Node
|
||||
// please use "paymentProcessingNode" type of node in the config (in the network.nodes array)
|
||||
peer, err := s.pool.Get(ctx, s.nodeconf.PaymentProcessingNodePeers()[0])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue