Current state of the server
Definition at line 14 of file server_state.py.
◆ __init__()
def coordinator.server_state.ServerState.__init__ |
( |
|
self, |
|
|
int |
next_contributor_index, |
|
|
int |
num_contributors, |
|
|
float |
next_contributor_deadline |
|
) |
| |
Definition at line 18 of file server_state.py.
20 next_contributor_index: int,
21 num_contributors: int,
22 next_contributor_deadline: float):
23 self.next_contributor_index: int = next_contributor_index
24 self.num_contributors: int = num_contributors
25 self.next_contributor_deadline: float = next_contributor_deadline
26 assert self.num_contributors != 0
◆ from_json()
ServerState coordinator.server_state.ServerState.from_json |
( |
str |
state_json | ) |
|
|
static |
Definition at line 32 of file server_state.py.
32 def from_json(state_json: str) -> ServerState:
33 return ServerState._from_json_dict(
34 json.loads(state_json))
◆ have_all_contributions()
bool coordinator.server_state.ServerState.have_all_contributions |
( |
|
self | ) |
|
returns True if all contributions have been received
Definition at line 36 of file server_state.py.
36 def have_all_contributions(self) -> bool:
38 returns True if all contributions have been received
40 return self.num_contributors <= self.next_contributor_index
◆ received_contribution()
None coordinator.server_state.ServerState.received_contribution |
( |
|
self, |
|
|
float |
next_deadline |
|
) |
| |
Update the state after new contribution has been successfully received.
Definition at line 42 of file server_state.py.
42 def received_contribution(self, next_deadline: float) ->
None:
44 Update the state after new contribution has been successfully received.
46 assert not self.have_all_contributions()
47 self._next_contributor(next_deadline)
◆ to_json()
str coordinator.server_state.ServerState.to_json |
( |
|
self | ) |
|
Definition at line 28 of file server_state.py.
28 def to_json(self) -> str:
29 return json.dumps(self._to_json_dict())
◆ update()
bool coordinator.server_state.ServerState.update |
( |
|
self, |
|
|
float |
now, |
|
|
float |
interval |
|
) |
| |
Check whether a contributor has missed his chance and update internal
state accordingly. If the deadline has passed, return True. Otherwise
return False.
Definition at line 49 of file server_state.py.
49 def update(self, now: float, interval: float) -> bool:
51 Check whether a contributor has missed his chance and update internal
52 state accordingly. If the deadline has passed, return True. Otherwise
56 if self.next_contributor_deadline <= 0.0
or \
57 now < self.next_contributor_deadline:
60 self._next_contributor(now + interval)
◆ next_contributor_deadline
coordinator.server_state.ServerState.next_contributor_deadline |
◆ next_contributor_index
coordinator.server_state.ServerState.next_contributor_index |
The documentation for this class was generated from the following file: