EOX GitLab Instance

Skip to content

Registration routes

Fabian Schindler-Strauss requested to merge routes into main

Adding implementation routes

A Route is bound to a queue and operates on a particular data-type (such as STAC Item, Collection, paths, arbitrary JSON structures).

Backends are also now generic according to its datatype and are now part of the route.

Each route also encapsulates the pre, post, and error handlers.

Example configuration:

routes:
  items:
    path: registrar.route.stac.ItemRoute
    queue: register
    output_queue: next_queue
    backends:
      - path: registrar.backend.eoxserver.ItemBackend
        kwargs:
          instance_base_path: /some/dir
          instance_name: name

    handlers:
      pre:
        - path: some.pre.handler
      post:
        - path: some.post.handler
      error:
        - path: some.error.handler

  collections:
    path: registrar.route.stac.CollectionRoute
    queue: register-collections
    backends:
      - path: registrar.backend.eoxserver.CollectionBackend

  path:
    path: registrar.route.path.PathRoute
    queue: register-paths
    backends:
      - path: some.path.backend

sources: [...]

This is how a STAC Item route can be implemented:

import json
import pystac

class ItemRoute(Route[pystac.Item]):
    """A route implementation for STAC Items"""

    def parse(self, raw: str) -> pystac.Item:
        return pystac.Item.from_dict(json.loads(raw))

    def get_source(
        self, source_cfgs: List[SourceConfig], item: pystac.Item
    ) -> Optional[Source]:
        return get_source(
            source_cfgs, [asset.href for asset in item.assets.values()]
        )

This is how the Backend interface can be satisfied:

from pystac import Item

# ...

class MyItemBackend(Backend[Item]):
    def exists(self, source: Optional[Source], item: Item) -> bool:
        ...

    def register(self, source: Optional[Source], item: Item, replace: bool):
        ...

    def deregister(self, source: Optional[Source], item: Item):
        ...

    def deregister_identifier(self, identifier: str):
        ...
Edited by Fabian Schindler-Strauss

Merge request reports