github.com/aergoio/aergo@v1.3.1/p2p/p2pcommon/actorservice.go (about)

     1  /*
     2   * @file
     3   * @copyright defined in aergo/LICENSE.txt
     4   */
     5  
     6  package p2pcommon
     7  
     8  import (
     9  	"github.com/aergoio/aergo-actor/actor"
    10  	"github.com/aergoio/aergo/types"
    11  	"time"
    12  )
    13  
    14  // ActorService is collection of helper methods to use actor
    15  // FIXME move to more general package. it used in p2p and rpc
    16  type ActorService interface {
    17  	// TellRequest send actor request, which does not need to get return value, and forget it.
    18  	TellRequest(actor string, msg interface{})
    19  	// SendRequest send actor request, and the response is expected to go back asynchronously.
    20  	SendRequest(actor string, msg interface{})
    21  	// CallRequest send actor request and wait the handling of that message to finished,
    22  	// and get return value.
    23  	CallRequest(actor string, msg interface{}, timeout time.Duration) (interface{}, error)
    24  	// CallRequestDefaultTimeout is CallRequest with default timeout
    25  	CallRequestDefaultTimeout(actor string, msg interface{}) (interface{}, error)
    26  
    27  	// FutureRequest send actor request and get the Future object to get the state and return value of message
    28  	FutureRequest(actor string, msg interface{}, timeout time.Duration) *actor.Future
    29  	// FutureRequestDefaultTimeout is FutureRequest with default timeout
    30  	FutureRequestDefaultTimeout(actor string, msg interface{}) *actor.Future
    31  
    32  	GetChainAccessor() types.ChainAccessor
    33  }
    34  //go:generate mockgen -source=actorservice.go  -package=p2pmock -destination=../p2pmock/mock_actorservice.go