p2pfl.communication.protocols.protobuff.server moduleΒΆ

Protobuff server.

class p2pfl.communication.protocols.protobuff.server.ProtobuffServer(gossiper, neighbors, commands=None)[source]ΒΆ

Bases: ABC, NodeServicesServicer, NodeComponent

Implementation of the server side logic of PROTOBUFF communication protocol.

Parameters:
  • addr – Address of the server.

  • gossiper (Gossiper) – Gossiper instance.

  • neighbors (Neighbors) – Neighbors instance.

  • commands (list[Command] | None) – List of commands to be executed by the server.

add_command(cmds)[source]ΒΆ

Add a command.

Parameters:

cmds (Command | list[Command]) – Command or list of commands to be added.

Return type:

None

disconnect(request, _)[source]ΒΆ

Service. It is called when a node disconnects from another.

Parameters:
  • request (HandShakeRequest) – Request message.

  • _ (ServicerContext) – Context.

  • _

Return type:

Empty

handshake(request, _)[source]ΒΆ

Service. It is called when a node connects to another.

Parameters:
  • request (HandShakeRequest) – Request message.

  • _ (ServicerContext) – Context.

  • _

Return type:

ResponseMessage

abstract is_running()[source]ΒΆ

Check if the server is running.

Return type:

bool

Returns:

True if the server is running, False otherwise.

send(request, _)[source]ΒΆ

Service. Handles both regular messages and model weights.

Parameters:
  • request (RootMessage) – The RootMessage containing either a Message or Weights payload.

  • _ (ServicerContext) – Context.

  • _

Return type:

ResponseMessage

abstract start(wait=False)[source]ΒΆ

Start the server.

Parameters:

wait (bool) – If True, wait for termination.

Return type:

None

abstract stop()[source]ΒΆ

Stop the server.

Return type:

None

abstract wait_for_termination()[source]ΒΆ

Wait for termination.

Return type:

None