msgdelivery

package
v0.0.0-...-05bc493 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReturnIDFlag uniproto.FlagIndex = iota
	RepeatedSendFlag
	HasBody
)
View Source
const (
	BodyRqListFlag uniproto.FlagIndex = iota
	BodyAckListFlag
	RejectListFlag
)

Flags for StatePacket

View Source
const ShortShipmentIDByteSize = 4

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressFlags

type AddressFlags uint32
const (
	DirectAddress AddressFlags = 0
	RoleAddress   AddressFlags = 1 << iota
)

type Config

type Config struct {
	TimeCycle        time.Duration
	MessageBatchSize uint
	MessageSender    SenderConfig
	StateSender      SenderConfig
}

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func NewController

func NewController(pt uniproto.ProtocolType, factory nwapi.DeserializationFactory,
	receiveFn ReceiverFunc, resolverFn ResolverFunc, logger uniserver.MiniLogger,
) *Controller

func (*Controller) NewFacade

func (p *Controller) NewFacade() Service

func (*Controller) RegisterWith

func (p *Controller) RegisterWith(regFn uniproto.RegisterControllerFunc)

for initialization only

func (*Controller) SetConfig

func (p *Controller) SetConfig(c Config)

for initialization only

type DedupID

type DedupID uint32

type DeliveryAddress

type DeliveryAddress struct {
	// contains filtered or unexported fields
}

func NewDirectAddress

func NewDirectAddress(id nwapi.ShortNodeID) DeliveryAddress

func NewRoleAddress

func NewRoleAddress(roleID uint8, dataSelector uint64) DeliveryAddress

func (DeliveryAddress) AsDirect

func (v DeliveryAddress) AsDirect() nwapi.Address

func (DeliveryAddress) IsZero

func (v DeliveryAddress) IsZero() bool

func (DeliveryAddress) ResolveWith

func (v DeliveryAddress) ResolveWith(fn ResolverFunc) nwapi.Address

type DeliveryPeer

type DeliveryPeer struct {
	// contains filtered or unexported fields
}

func (*DeliveryPeer) Close

func (p *DeliveryPeer) Close() error

func (*DeliveryPeer) NextShipmentID

func (p *DeliveryPeer) NextShipmentID() ShipmentID

type DeliveryPolicies

type DeliveryPolicies uint8
const (
	// FireAndForget indicates that this delivery doesn't need ACK. Can only be applied to head-only parcels
	FireAndForget DeliveryPolicies = 1 << iota
	// ExpectedParcel indicates that receiver expects this shipment, and the shipment should be delivered as head+body
	ExpectedParcel

	ExactPulse
)

type PacketType

type PacketType uint8
const (
	DeliveryState PacketType = iota
	DeliveryParcelHead
	DeliveryParcelComplete
)

type ParcelPacket

type ParcelPacket struct {
	PulseNumber  pulse.Number `insolar-transport:"aliasOf=Packet.PulseNumber"`
	ParcelID     ShortShipmentID
	ReturnID     ShortShipmentID           `insolar-transport:"Packet=1,2;optional=PacketFlags[0]"`
	BodyScale    uint8                     `insolar-transport:"Packet=1"` // bits.Len(byteSize(body+head))
	TTLCycles    uint8                     `insolar-transport:"Packet=1"` // adjusted by PN
	ParcelType   nwapi.PayloadCompleteness `insolar-transport:"send=ignore"`
	RepeatedSend bool                      `insolar-transport:"aliasOf=PacketFlags[1]"`

	Data nwapi.SizeAwareSerializer // nwapi.Serializable

	OnDataReceiveFn func(*uniproto.Packet, *ParcelPacket, func() error) error `insolar-transport:"send=ignore"`
}

func (*ParcelPacket) DeserializePayload

func (p *ParcelPacket) DeserializePayload(ctx nwapi.DeserializationContext, packet *uniproto.Packet, reader *iokit.LimitedReader) error

func (*ParcelPacket) PreparePacket

func (p *ParcelPacket) PreparePacket() (packet uniproto.PacketTemplate, dataSize uint, fn uniproto.PayloadSerializerFunc)

func (*ParcelPacket) SerializePayload

func (p *ParcelPacket) SerializePayload(ctx nwapi.SerializationContext, packet *uniproto.Packet, writer *iokit.LimitedWriter) error

type ReceiverFunc

type ReceiverFunc func(ReturnAddress, nwapi.PayloadCompleteness, interface{}) error

type ResolverFunc

type ResolverFunc func(addrType AddressFlags, nodeSelector uint32, dataSelector uint64) nwapi.Address

type ReturnAddress

type ReturnAddress struct {
	// contains filtered or unexported fields
}

func (ReturnAddress) IsValid

func (v ReturnAddress) IsValid() bool

func (ReturnAddress) IsZero

func (v ReturnAddress) IsZero() bool

func (ReturnAddress) String

func (v ReturnAddress) String() string

type SenderConfig

type SenderConfig struct {
	RetryIntervals [retries.RetryStages]time.Duration

	FastQueue  int
	RetryQueue int

	SenderWorkerConfig
}

type SenderWorkerConfig

type SenderWorkerConfig struct {
	ParallelWorkers        int
	ParallelPeersPerWorker int
	MaxPostponedPerWorker  int
}

type Service

type Service interface {
	ShipTo(to DeliveryAddress, shipment Shipment) error
	ShipReturn(to ReturnAddress, shipment Shipment) error
	PullBody(from ReturnAddress, shipmentRq ShipmentRequest) error
	RejectBody(from ReturnAddress) error
}

type Shipment

type Shipment struct {
	Head   nwapi.SizeAwareSerializer
	Body   nwapi.SizeAwareSerializer
	Cancel *synckit.ChainedCancel
	PN     pulse.Number
	// TTL defines how many pulses this shipment can survive before cancellation
	TTL      uint8
	Policies DeliveryPolicies
}

body = whole, body contains head

type ShipmentID

type ShipmentID uint64 // NodeId + ShortShipmentID

func AsShipmentID

func AsShipmentID(node uint32, id ShortShipmentID) ShipmentID

func (ShipmentID) NodeID

func (v ShipmentID) NodeID() uint32

func (ShipmentID) ShortID

func (v ShipmentID) ShortID() ShortShipmentID

type ShipmentRequest

type ShipmentRequest struct {
	ReceiveFn ReceiverFunc
	Cancel    *synckit.ChainedCancel
}

type ShipmentState

type ShipmentState uint8
const (
	WaitAck ShipmentState
	BodyReady
	BodyRequested
	BodySending
	WaitBodyAck
	Done
	Rejected
	Expired
	Cancelled
)

type ShortShipmentID

type ShortShipmentID uint32

func ShortShipmentIDReadFrom

func ShortShipmentIDReadFrom(reader io.Reader) (ShortShipmentID, error)

func ShortShipmentIDReadFromBytes

func ShortShipmentIDReadFromBytes(b []byte) ShortShipmentID

func (ShortShipmentID) PutTo

func (v ShortShipmentID) PutTo(b []byte) int

func (ShortShipmentID) SimpleWriteTo

func (v ShortShipmentID) SimpleWriteTo(writer io.Writer) error

type StatePacket

type StatePacket struct {
	// From receiver to sender
	BodyRqList []ShortShipmentID `insolar-transport:"optional=PacketFlags[0]"` //
	// From receiver to sender
	BodyAckList []ShortShipmentID `insolar-transport:"optional=PacketFlags[1]"` // TODO serialization / deser
	// From receiver to sender
	RejectList []ShortShipmentID `insolar-transport:"optional=PacketFlags[2]"` //
	// From receiver to sender
	AckList []ShortShipmentID `insolar-transport:"list=nocount"` // length is determined by packet size
}

func (*StatePacket) DeserializePayload

func (p *StatePacket) DeserializePayload(_ nwapi.DeserializationContext, packet *uniproto.Packet, reader *iokit.LimitedReader) (err error)

func (*StatePacket) PreparePacket

func (p *StatePacket) PreparePacket() (packet uniproto.PacketTemplate, dataSize uint, fn uniproto.PayloadSerializerFunc)

func (*StatePacket) SerializePayload

func (p *StatePacket) SerializePayload(_ nwapi.SerializationContext, _ *uniproto.Packet, writer *iokit.LimitedWriter) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL