jina.types.routing.table module

class jina.types.routing.table.TargetPod(target)[source]

Bases: jina.types.mixin.ProtoTypeMixin

Wrapper class around TargetPodProto.

It offers a Pythonic interface to allow users access to the jina.jina_pb2.TargetPodProto object without working with Protobuf itself.

Parameters

target (TargetPodProto) – the protobuf object of the TargetPod

property port: int

Returns the port field of this TargetPod

Return type

int

Returns

port

property port_out: int

Returns the port field of this TargetPod

Return type

int

Returns

port

property host: str

Returns the host field of this TargetPod

Return type

str

Returns

host

property full_address: str

Return the full zmq adress of this TargetPod

Return type

str

Returns

address

property full_out_address: str

Return the full zmq adress of the tail of this TargetPod

Return type

str

Returns

address

property expected_parts: int

Return the expected_parts field of this TargetPod

Return type

int

Returns

expected_parts

property out_edges: List[str]

Return the out_edges field of this TargetPod

Return type

List[str]

Returns

out_edges

add_edge(to_pod, send_as_bind)[source]

Adds an edge to the internal representation of the out_edges.

Parameters
  • to_pod (str) – the name of the pod outtraffic should go to

  • send_as_bind (bool) – True, if the TailPea should send via its ROUTER_BIND socket.

Return type

None

class jina.types.routing.table.RoutingTable(graph=None, copy=False)[source]

Bases: jina.types.mixin.ProtoTypeMixin

Wrapper class around RoutingTableProto.

It offers a Pythonic interface to allow users access to the jina.jina_pb2.RoutingTableProto object without working with Protobuf itself.

Parameters

graph (Union[RoutingTableProto, bytes, dict, str, RoutingTable, None]) – the protobuf object of the RoutingTable

add_edge(from_pod, to_pod, send_as_bind=False)[source]

Adds an edge to the graph.

Parameters
  • from_pod (str) – Pod from which traffic is send

  • to_pod (str) – Pod to which traffic is send

  • send_as_bind (bool) – True, if the TailPea of the from_pod should send via its ROUTER_BIND socket.

Return type

None

add_pod(pod_name, head_host, head_port_in, tail_port_out, head_zmq_identity)[source]

Adds a Pod vertex to the graph.

Parameters
  • pod_name (str) – the name of the Pod. Should be unique to the graph.

  • head_host – head host of the pod

  • head_port_in – port in of the head of the pod

  • tail_port_out – port out of the tail of the pod

  • head_zmq_identity – identity of the head - only relevant for zmq

Return type

None

property active_pod: str
Return type

str

Returns

the active Pod name

property active_target_pod: jina.types.routing.table.TargetPod
Return type

TargetPod

Returns

a TargetPod object of the currently active Pod

property pods
Returns

all Pod/vertices of the graph.

get_next_targets()[source]

Calculates next routing graph for all currently outgoing edges.

Return type

List[RoutingTable]

Returns

new routing graphs with updated active Pods.

get_next_target_addresses()[source]

Calculates next routing targets for all currently outgoing edges.

Return type

List[str]

Returns

list of addresses for next targets

is_acyclic()[source]
Return type

bool

Returns

True, if graph is acyclic, False otherwise.