github.com/braveheart12/just@v0.8.7/core/network.go (about)

     1  /*
     2   *    Copyright 2019 Insolar Technologies
     3   *
     4   *    Licensed under the Apache License, Version 2.0 (the "License");
     5   *    you may not use this file except in compliance with the License.
     6   *    You may obtain a copy of the License at
     7   *
     8   *        http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   *    Unless required by applicable law or agreed to in writing, software
    11   *    distributed under the License is distributed on an "AS IS" BASIS,
    12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   *    See the License for the specific language governing permissions and
    14   *    limitations under the License.
    15   */
    16  
    17  package core
    18  
    19  import (
    20  	"context"
    21  )
    22  
    23  // Cascade contains routing data for cascade sending
    24  type Cascade struct {
    25  	// NodeIds contains the slice of node identifiers that will receive the message
    26  	NodeIds []RecordRef
    27  	// GeneratedEntropy is used for pseudorandom cascade building
    28  	Entropy Entropy
    29  	// Replication factor is the number of children nodes of the each node of the cascade
    30  	ReplicationFactor uint
    31  }
    32  
    33  // RemoteProcedure is remote procedure call function.
    34  type RemoteProcedure func(ctx context.Context, args [][]byte) ([]byte, error)
    35  
    36  // Network is interface for network modules facade.
    37  type Network interface {
    38  	// SendParcel sends a message.
    39  	SendMessage(nodeID RecordRef, method string, msg Parcel) ([]byte, error)
    40  	// SendCascadeMessage sends a message.
    41  	SendCascadeMessage(data Cascade, method string, msg Parcel) error
    42  	// RemoteProcedureRegister is remote procedure register func.
    43  	RemoteProcedureRegister(name string, method RemoteProcedure)
    44  }
    45  
    46  // PulseDistributor is interface for pulse distribution.
    47  //go:generate minimock -i github.com/insolar/insolar/core.PulseDistributor -o ../testutils -s _mock.go
    48  type PulseDistributor interface {
    49  	// Distribute distributes a pulse across the network.
    50  	Distribute(context.Context, Pulse)
    51  }