wrnt

package
v0.0.0-...-32a2d26 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

The wrnt package provides send and recv components for guaranteed delivery of string messages with acknowledgment of receipt. Transmission is carried out by the user.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotInited = errors.New("not inited")

Functions

This section is empty.

Types

type Message

type Message struct {
	//starting index
	BaseN int
	//items, with index from
	Items []string
}

message to be send from send to recv holds all non-confirmed items

type Recv

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

Recv is receiver-side component that Unpack messages into unique items

func NewRecv

func NewRecv() *Recv

func (*Recv) LastRecv

func (r *Recv) LastRecv() int

LastRecv return last received item that must be transported to send-part by user

func (*Recv) Unpack

func (r *Recv) Unpack(msg Message) []string

Unpack return unique items from message already received items are not returned update lastN received item if needed

type Send

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

Send is a send-side component of wrnt package new Send doesn't count as inited before first Confirm call so Confirm with last received item must be guaranteed

func NewSend

func NewSend() *Send

func (*Send) AddItems

func (s *Send) AddItems(items ...string)

AddItems add new items to send may be called before initiation all added items are not confirmed and must be sent

func (*Send) Confirm

func (s *Send) Confirm(n int)

Confirm the fact of receiving messages up to index N after Confirm call Send is inited

func (*Send) DropNotSent

func (s *Send) DropNotSent()

DropNotSent moves ConfirmedN to the end of storage marking all items as confirmed. by fact, they may be already received or not received but they will never be sent again

func (*Send) Pack

func (s *Send) Pack() (msg Message, err error)

Pack returns a Message according to ConfirmedN user must transport it to receiver-side if send is not inited Pack returns ErrNotInited error

type SendMany

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

func NewSendMany

func NewSendMany(names []string) *SendMany

func (*SendMany) AddItems

func (sm *SendMany) AddItems(items ...string)

func (*SendMany) Confirm

func (sm *SendMany) Confirm(name string, n int) error

func (*SendMany) DropNotSent

func (sm *SendMany) DropNotSent()

func (*SendMany) Pack

func (sm *SendMany) Pack(name string) (msg Message, err error)

Jump to

Keyboard shortcuts

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