"""Registration adapter; the owner supplies the service and starts the node."""
from easyremote import ComputeNode, Context
from audit_demo import Call, StatusService


def create_node(service: StatusService) -> ComputeNode:
    node = ComputeNode(namespace="status_lookup")

    @node.register
    def query_status(ctx: Context, reference: str) -> dict:
        """Return only the status of a record authorized for this caller."""
        return service.query(Call(ctx.caller, ctx.invocation_id), reference)

    return node
