sequence

This paper mainly studies broadcastCluster of Dubo-Go

broadcastCluster

Dubbo – go – v1.4.2 / cluster/cluster_impl broadcast_cluster. Go

type broadcastCluster struct{}

const broadcast = "broadcast"

func init() {
	extension.SetCluster(broadcast, NewBroadcastCluster)
}

// NewBroadcastCluster ...
func NewBroadcastCluster() cluster.Cluster {
	return &broadcastCluster{}
}

func (cluster *broadcastCluster) Join(directory cluster.Directory) protocol.Invoker {
	return newBroadcastClusterInvoker(directory)
}
Copy the code
  • NewBroadcastClusterInvoker broadcastCluster join method of execution

newBroadcastClusterInvoker

Dubbo – go – v1.4.2 / cluster/cluster_impl broadcast_cluster_invoker. Go

type broadcastClusterInvoker struct {
	baseClusterInvoker
}

func newBroadcastClusterInvoker(directory cluster.Directory) protocol.Invoker {
	return &broadcastClusterInvoker{
		baseClusterInvoker: newBaseClusterInvoker(directory),
	}
}
Copy the code
  • Instantiation broadcastClusterInvoker newBroadcastClusterInvoker method

Invoke

Dubbo – go – v1.4.2 / cluster/cluster_impl broadcast_cluster_invoker. Go

func (invoker *broadcastClusterInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { invokers := invoker.directory.List(invocation) err := invoker.checkInvokers(invokers, invocation) if err ! = nil { return &protocol.RPCResult{Err: err} } err = invoker.checkWhetherDestroyed() if err ! = nil { return &protocol.RPCResult{Err: err} } var result protocol.Result for _, ivk := range invokers { result = ivk.Invoke(ctx, invocation) if result.Error() ! = nil { logger.Warnf("broadcast invoker invoke err: %v when use invoker: %v\n", result.Error(), ivk) err = result.Error() } } if err ! = nil { return &protocol.RPCResult{Err: err} } return result }Copy the code
  • Invoke invocation Invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation Err is returned if the last err is not nil, otherwise the last result is returned

summary

The join method perform newBroadcastClusterInvoker broadcastCluster; Invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation invocation Err is returned if the last err is not nil, otherwise the last result is returned

doc

  • broadcast_cluster