-
Notifications
You must be signed in to change notification settings - Fork 3
/
maininterface.iol
executable file
·159 lines (124 loc) · 3.26 KB
/
maininterface.iol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Timers
type TimerRequest: int {
.port: string
}
interface TimerInterface {
OneWay: timeout(undefined),
SetVisualizerTimer(TimerRequest),
VisualizerTimeout(void),
SetHeartbeatTimer(TimerRequest),
HeartbeatTimeoutA(void),
HeartbeatTimeoutB(void),
HeartbeatTimeoutC(void),
HeartbeatTimeoutD(void),
SetElectionTimer(TimerRequest),
ElectionTimeout(void),
}
// Election
type RRRequestVoteType : void{
.term : int
.candidateID : int
.lastLogIndex : int
.lastLogTerm : int
}
type RRVoteType : void {
.VoteGranted: bool
.Term: int
}
type HeartbeatType : void{
.result : bool
.leaderID : string
}
interface ElectionInterface {
RequestResponse: RequestVote(RRRequestVoteType)(RRVoteType)
OneWay: Heartbeat(HeartbeatType)
}
// AppendEntries
type LogEntry: void {
.entry: RequestType | void
.adminAction: bool
.term: int
}
type AppendEntriesType: void {
.term: int //termine del leader in quel momento
.leaderID: int //l'identificativo del server che ha mandato (presumibilmente il leader)
.prevLogIndex: int // indice della voce del log immediatamente precedente le nuove voci da aggiungere
.prevLogTerm: int | void //il termine della voce del log indicata da prevLogIndex
.entries*: LogEntry | void // le voci del log da includere (se è un hertbeat sarà vuoto)
.leaderCommit: int //commitIndex del Leader
}
type AckType: void {
.term: int
.success: bool
.senderID: int
.lastIndex: int // Per aggiornare il nexIndices del leader con l'ultimo elemento del log del server
.isHeartbeat: bool
.replicatedIndex?: int
.replicatedTerm?: int
.conflictingIndex?: int
}
interface ServerInterface {
OneWay: AppendEntries(AppendEntriesType),
Ack(AckType)
}
// NetworkVisualizer
type LeaderType: void {
.id: int
.port: string
}
type ServersStatusType: void {
.status*: bool
}
type VisualizerType: void {
.leader: LeaderType
.servers: ServersStatusType
.items: undefined
.carts: undefined
}
interface VisualizerInterface {
OneWay: GlobalStatus(VisualizerType)
}
// Admin/Client Interface
type EditCartType:void {
.name:string
}
type EditItemInCartType:void {
.cartName:string
.itemName:string
.itemQnt:undefined
}
type EditItemInListType:void {
.itemName:string
.itemQnt:undefined
}
type BasicResponse:void {
.result:bool
.msg:string
}
type LeaderAddress: void {
.address:string
}
type RequestType: void {
.code: int
.data: EditItemInCartType | EditItemInListType | EditCartType | void | string // String è per l'integrazione html, che non può trasferire void
}
type ResponseType: LeaderAddress | BasicResponse | undefined
// > Admin/Client to Server
interface ClientInterface {
RequestResponse: ClientRequest(RequestType)(ResponseType),
ClientHTTPDefault(undefined)(undefined)
}
interface AdminInterface {
RequestResponse: AdminRequest(RequestType)(ResponseType),
AdminHTTPDefault(undefined)(undefined)
}
// > Server to Micro-Service
interface ClientActionInterface {
RequestResponse: ClientAction(RequestType)(ResponseType)
}
interface AdminActionInterface {
RequestResponse: AdminAction(RequestType)(ResponseType)
}
interface VisualizerActionInterface {
RequestResponse: GetShopStatus(void)(undefined)
}