koi_net.components.interfaces.knowledge_handler

Classes

HandlerType(*values)

Types of handlers used in knowledge processing pipeline.

KnowledgeHandler(log, pipeline)

Handles knowledge processing events of the provided types.

StopChain()

Class for STOP_CHAIN sentinel returned by knowledge handlers.

class koi_net.components.interfaces.knowledge_handler.HandlerType(*values)[source]

Bases: StrEnum

Types of handlers used in knowledge processing pipeline.

  • RID - provided RID; if event type is FORGET, this handler decides whether to delete the knowledge from the cache by setting the normalized event type to FORGET, otherwise this handler decides whether to validate the manifest (and fetch it if not provided).

  • Manifest - provided RID, manifest; decides whether to validate the bundle (and fetch it if not provided).

  • Bundle - provided RID, manifest, contents (bundle); decides whether to write knowledge to the cache by setting the normalized event type to NEW or UPDATE.

  • Network - provided RID, manifest, contents (bundle); decides which nodes (if any) to broadcast an event about this knowledge to. (Note, if event type is FORGET, the manifest and contents will be retrieved from the local cache, and indicate the last state of the knowledge before it was deleted.)

  • Final - provided RID, manifests, contents (bundle); final action taken after network broadcast.

Bundle = 'bundle'
Final = 'final'
Manifest = 'manifest'
Network = 'network'
RID = 'rid'
class koi_net.components.interfaces.knowledge_handler.KnowledgeHandler(log, pipeline)[source]

Bases: object

Handles knowledge processing events of the provided types.

Parameters:
event_types: tuple[EventType | None] = ()
handle(kobj)[source]
Return type:

KnowledgeObject | None | StopChain

Parameters:

kobj (KnowledgeObject)

handler_type: HandlerType
log: Logger
pipeline: KnowledgePipeline
rid_types: tuple[RIDType] = ()
class koi_net.components.interfaces.knowledge_handler.StopChain[source]

Bases: object

Class for STOP_CHAIN sentinel returned by knowledge handlers.