Documentation ¶
Index ¶
- Constants
- func ShortID(self string) string
- type Clock
- type MessageLog
- type MiddlewareLC
- func (middleware *MiddlewareLC) ExecSystemMessage(message *api.MessageLC)
- func (middleware *MiddlewareLC) GetGroupID() string
- func (middleware *MiddlewareLC) GetGroupSize() int
- func (middleware *MiddlewareLC) GetRank() (int, error)
- func (middleware *MiddlewareLC) GetShortID() string
- func (middleware *MiddlewareLC) Recv(ctx context.Context) (string, error)
- func (middleware *MiddlewareLC) RecvAndUpdate() *api.MessageLC
- func (middleware *MiddlewareLC) RecvMsg(ctx context.Context) (*api.MessageLC, error)
- func (middleware *MiddlewareLC) RecvWork()
- func (middleware *MiddlewareLC) Send(ctx context.Context, message string) error
- func (middleware *MiddlewareLC) SendAck(ctx context.Context, message *api.MessageLC) error
- func (middleware *MiddlewareLC) SendSys(ctx context.Context, event SystemEvent, try bool) error
- func (middleware *MiddlewareLC) Stop()
- func (middleware *MiddlewareLC) WaitToStart(ctx context.Context) error
- type MulticastGroup
- func (group *MulticastGroup) GetID(rank int) (string, error)
- func (group *MulticastGroup) GetMyID() string
- func (group *MulticastGroup) GetMyRank() (int, error)
- func (group *MulticastGroup) GetRank(ID string) (int, error)
- func (group *MulticastGroup) GetShortID() string
- func (group *MulticastGroup) GetUsersInfo() ([]net.Addr, []string, []int, error)
- type Status
- type SystemEvent
- type Users
Constants ¶
const ( TO_SEND Status = 0 SENT = 1 RECEIVED = 2 FAILED_TO_SEND = 3 TO_SEND_ACK = 4 SENT_ACK = 5 RECEIVED_ACK = 6 )
const ( EXIT SystemEvent = 0 FATAL = 1 START = 2 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MessageLog ¶
type MessageLog struct {
// contains filtered or unexported fields
}
func NewMessageLog ¶
func NewMessageLog(out *os.File) *MessageLog
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) RecvWork ¶
func (middleware *MiddlewareLC) RecvWork()
Lavoro di background del MiddlewareLC:
- Riceve un nuovo messaggio ed aggiorna il clock
- Se è un messaggio invia l'ack ed inseriscilo nella coda di ricezione.
- 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 ¶
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 (*MulticastGroup) GetMyID ¶
func (group *MulticastGroup) GetMyID() string
func (*MulticastGroup) GetMyRank ¶
func (group *MulticastGroup) GetMyRank() (int, error)
func (*MulticastGroup) GetShortID ¶
func (group *MulticastGroup) GetShortID() string
func (*MulticastGroup) GetUsersInfo ¶
type SystemEvent ¶
type SystemEvent int
func EventFromString ¶
func EventFromString(eventStr string) (SystemEvent, error)
func (SystemEvent) String ¶
func (event SystemEvent) String() string