graflo.connections.kinds¶
Every kind of connection as one typed union, and the roles each kind plays.
A connection is a database, a REST API, a stream or a place files live. Each
config carries a kind (and a database its db_type), so a stored
connection always parses back to the same class, and what it can be used for
follows from the config alone, without contacting anything.
Attributes¶
AnyConnection = DBConfig | RestApiConnConfig | KafkaConnConfig | FilesConnConfig
module-attribute
¶
The runtime type of a parsed :data:Connection.
CONNECTION_ADAPTER = TypeAdapter(Connection)
module-attribute
¶
Connection = Annotated[DatabaseConnection | RestApiConnConfig | KafkaConnConfig | FilesConnConfig, Field(discriminator='kind')]
module-attribute
¶
Any connection, discriminated by kind (a database further by db_type).
DatabaseConnection = Annotated[Annotated[ArangoConfig, Tag('arango')] | Annotated[Neo4jConfig, Tag('neo4j')] | Annotated[TigergraphConfig, Tag('tigergraph')] | Annotated[FalkordbConfig, Tag('falkordb')] | Annotated[MemgraphConfig, Tag('memgraph')] | Annotated[NebulaConfig, Tag('nebula')] | Annotated[GraFloBackendConfig, Tag('graflo_backend')] | Annotated[PostgresConfig, Tag('postgres')] | Annotated[SparqlEndpointConfig, Tag('sparql')] | Annotated[GraphDBConfig, Tag('graphdb')], Discriminator(_database_tag)]
module-attribute
¶
A database connection, discriminated by db_type.
__all__ = ['CONNECTION_ADAPTER', 'AnyConnection', 'Connection', 'ConnectionKind', 'DatabaseConnection', 'Role', 'connection_kind', 'parse_connection', 'roles']
module-attribute
¶
Classes¶
ConnectionKind
¶
Bases: StrEnum
What a connection reaches.
Source code in graflo/connections/kinds.py
Role
¶
Bases: StrEnum
What a connection is used as: read from, or written to.
Source code in graflo/connections/kinds.py
Functions:¶
connection_kind(conn)
¶
parse_connection(data)
¶
The connection data describes.
kind is required. A database also needs db_type and is read by
:meth:DBConfig.from_dict, which accepts its URI spelt in parts.
Raises:
| Type | Description |
|---|---|
ValueError
|
The kind is missing or unknown, or the config does not validate for it. |
Source code in graflo/connections/kinds.py
roles(conn)
¶
What conn can be used as, from its kind and flavour alone.
An API, a stream and a files connection are read from. A database is read
from when a connector reads its rows (:data:SOURCE_DATABASES) and written
to when it holds a graph (:data:TARGET_DATABASES); PostgreSQL is both.