Documentation
¶
Overview ¶
Package grpcproctest runs a grpcproc cluster inside one test binary. Nodes talk over in-memory gRPC connections (bufconn), so a multi-node scenario, including a partition or a node dying, needs no sockets and no registry.
Its nodes dial a peer again at once after a dial to it failed (Config.DialBackoff is negative), so the send right after Heal or Restart reaches the peer. Set DialBackoff with WithConfig to test the backoff.
Index ¶
- type Cluster
- func (c *Cluster) Conn(name string) *grpc.ClientConn
- func (c *Cluster) DialOptions() []grpc.DialOption
- func (c *Cluster) Heal(a, b string)
- func (c *Cluster) Kill(name string)
- func (c *Cluster) Node(name string) *grpcproc.Node
- func (c *Cluster) Partition(a, b string)
- func (*Cluster) Resolver() grpcproc.Resolver
- func (c *Cluster) Restart(name string) *grpcproc.Node
- func (c *Cluster) Stop(name string)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster is a set of nodes and the (simulated) network between them.
func (*Cluster) Conn ¶
func (c *Cluster) Conn(name string) *grpc.ClientConn
Conn returns a client connection to the gRPC server of node name, for calling services registered with WithServices. It is not subject to Partition, and it follows the node across Restart.
func (*Cluster) DialOptions ¶
func (c *Cluster) DialOptions() []grpc.DialOption
DialOptions reach the cluster's in-memory servers from outside any node: not subject to Partition, and following a node across Restart.
func (*Cluster) Kill ¶
Kill stops name abruptly, as a crash would: no Down{shutdown} reaches anyone; peers see their links break. They have by the time Kill returns, monitors fired and calls failed, so the next send to name fails, and after Restart reaches the new node (dials are not backed off; see the package doc).
func (*Cluster) Partition ¶
Partition cuts the network between a and b in both directions: existing links break (monitors fire Down{noconnection}) and new dials are refused until Heal.
func (*Cluster) Resolver ¶
Resolver resolves node names of this cluster, for components that dial nodes themselves (an Inspector built with inspect.WithResolver). Use it with DialOptions.
type Option ¶
type Option func(*Cluster)
Option configures a Cluster.
func WithConfig ¶
WithConfig adjusts each node's Config before the node is created, each time it starts (including after Restart): a Registrar, a Membership, hooks for one node only.
func WithLogger ¶
WithLogger sets the logger every node uses. Default: discards.