linkahead.connection.interface module

This module defines the CaosDBServerConnection interface.

class linkahead.connection.interface.CaosDBHTTPResponse

Bases: ABC

An abstract class which defines a minimal interface for responses of the LinkAheadServer.

abstract close()

close.

Close this response. Depending on the implementation this might also close underlying streams, sockets etc.

abstract getheader(name: str, default=None)

Return the value of the header name or the value of default if there is no such header.

If there are multiple headers with that name, return all of the values joined by ‘, ‘. If default is an iterable, its elements are returned likewise.

abstract getheaders() dict[str, str]

Return all headers.

abstract read(size: int | None = -1)

Read up to size bytes from the response body.

If size is unspecified or -1, all bytes until EOF are returned.

abstract property status: int

Status code of the response.

class linkahead.connection.interface.CaosDBServerConnection

Bases: ABC

Abstract class which defines the interface for sending requests to the LinkAhead server.

abstract configure(**kwargs)

Configure the connection. This method is to be called by configure_connection.

Return type:

None

abstract request(method: str, path: str, headers: dict[str, str] | None = None, body: str | bytes | None = None, **kwargs) CaosDBHTTPResponse

Abstract method. Implement this method for HTTP requests to the LinkAhead server.

Return type:

CaosDBHTTPResponse