clientlc

package
v0.0.0-...-b7a815f Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TO_SEND        Status = 0
	SENT                  = 1
	RECEIVED              = 2
	FAILED_TO_SEND        = 3
	TO_SEND_ACK           = 4
	SENT_ACK              = 5
	RECEIVED_ACK          = 6
)
View Source
const (
	EXIT  SystemEvent = 0
	FATAL             = 1
	START             = 2
)

Variables

This section is empty.

Functions

func ShortID

func ShortID(self string) string

Types

type Clock

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

func NewClock

func NewClock() *Clock

func (*Clock) GetClock

func (cl *Clock) GetClock() uint64

func (*Clock) Increase

func (cl *Clock) Increase() uint64

func (*Clock) Lock

func (cl *Clock) Lock()

func (*Clock) Unlock

func (cl *Clock) Unlock()

func (*Clock) Update

func (cl *Clock) Update(clock uint64) uint64

type MessageLog

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

func NewMessageLog

func NewMessageLog(out *os.File) *MessageLog

func (*MessageLog) Log

func (log *MessageLog) Log(status Status, message *api.MessageLC) error

func (*MessageLog) WriteLog

func (log *MessageLog) WriteLog(status Status, message *api.MessageLC) error

type MiddlewareLC

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

func NewMiddlewareLC

func NewMiddlewareLC(self, groupName, logPath string, port int, nameserver *nameservice.NameServiceClient, verbose bool, trySend bool, dopt []grpc.DialOption, sopt []grpc.ServerOption) (*MiddlewareLC, error)

Instanza un nuovo Middleware: self: il mio id all 'interno del gruppo groupName: nome del gruppo logPath: path del file dove verra scritto il log di rete. port: porta di ascolte del server grpc. nameserver: client grpc del nameserver verbose: modalita di operazione debug. trySend: indica di non provare a rimandare i messaggi falliti, utile per il debug. dopt: opzioni per i client grpc sopt: Opzioni per il server grpc

func (*MiddlewareLC) ExecSystemMessage

func (middleware *MiddlewareLC) ExecSystemMessage(message *api.MessageLC)

func (*MiddlewareLC) GetGroupID

func (middleware *MiddlewareLC) GetGroupID() string

func (*MiddlewareLC) GetGroupSize

func (middleware *MiddlewareLC) GetGroupSize() int

func (*MiddlewareLC) GetRank

func (middleware *MiddlewareLC) GetRank() (int, error)

func (*MiddlewareLC) GetShortID

func (middleware *MiddlewareLC) GetShortID() string

func (*MiddlewareLC) Recv

func (middleware *MiddlewareLC) Recv(ctx context.Context) (string, error)

Recv:

Ricevi il prossimo messaggio, la semantica è bloccante.

func (*MiddlewareLC) RecvAndUpdate

func (middleware *MiddlewareLC) RecvAndUpdate() *api.MessageLC

RecvAndUpdate Recv un messaggio dalla MulticastSocket ed aggiorna il clock logico correttamente. L'intera logica dell'evento Receive è qui dentro.

func (*MiddlewareLC) RecvMsg

func (middleware *MiddlewareLC) RecvMsg(ctx context.Context) (*api.MessageLC, error)

RecvMsg: Ritorna l'intero messaggio è non solo il dato.

func (*MiddlewareLC) RecvWork

func (middleware *MiddlewareLC) RecvWork()

Lavoro di background del MiddlewareLC:

  1. Riceve un nuovo messaggio ed aggiorna il clock
  2. Se è un messaggio invia l'ack ed inseriscilo nella coda di ricezione.
  3. Se è un ack, non inviare un altro ack ma inseriscilo comunque nella coda di ricezione.

func (*MiddlewareLC) Send

func (middleware *MiddlewareLC) Send(ctx context.Context, message string) error

Send:

Invia il messaggio input in broadcast a tutti i membri del gruppo noi inclusi.

func (*MiddlewareLC) SendAck

func (middleware *MiddlewareLC) SendAck(ctx context.Context, message *api.MessageLC) error

SendAck: Invia l'ack del messaggio di input in broadcast al gruppo noi inclusi.

func (*MiddlewareLC) SendSys

func (middleware *MiddlewareLC) SendSys(ctx context.Context, event SystemEvent, try bool) error

SendSys:

Send per messaggi di sistema.

func (*MiddlewareLC) Stop

func (middleware *MiddlewareLC) Stop()

Stop

indica la volonta di terminare correttamente la comunicazione multicast.
NB: i messaggi qui vengono inviati senza resend in caso di fallimento perché se
i peer iniziano a chiudere aspetteremmo indefinitamente per la risposta di un peer che non è piú on.

func (*MiddlewareLC) WaitToStart

func (middleware *MiddlewareLC) WaitToStart(ctx context.Context) error

type MulticastGroup

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

func NewGroup

func NewGroup(self string, users []*pb.User) *MulticastGroup

func (*MulticastGroup) GetID

func (group *MulticastGroup) GetID(rank int) (string, error)

func (*MulticastGroup) GetMyID

func (group *MulticastGroup) GetMyID() string

func (*MulticastGroup) GetMyRank

func (group *MulticastGroup) GetMyRank() (int, error)

func (*MulticastGroup) GetRank

func (group *MulticastGroup) GetRank(ID string) (int, error)

func (*MulticastGroup) GetShortID

func (group *MulticastGroup) GetShortID() string

func (*MulticastGroup) GetUsersInfo

func (group *MulticastGroup) GetUsersInfo() ([]net.Addr, []string, []int, error)

type Status

type Status int

func (Status) String

func (status Status) String() string

type SystemEvent

type SystemEvent int

func EventFromString

func EventFromString(eventStr string) (SystemEvent, error)

func (SystemEvent) String

func (event SystemEvent) String() string

type Users

type Users []*pb.User

func (Users) Len

func (users Users) Len() int

func (Users) Less

func (users Users) Less(i, j int) bool

func (Users) Swap

func (users Users) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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