tlc.service.object_service

The 3LC Object Service.

Module Contents

Classes

Class

Description

LitestarStateConstants

Constants for the Litestar state.

ObjectServiceFeatures

ObjectServiceUserInfo

DashboardAnnotations

TLCCustomLoggingMiddleware

Custom middleware to log object service requests and responses.

NGrokOutputAdaptor

Helper class to format output from NGrokHelper for the Object Service.

Functions

Function

Description

internal_server_error_handler

Catch-all for application errors.

insufficient_credits_handler

Handler for insufficient credits.

timestamp_skew_handler

Handler for timestamp skew.

get_ip_addresses

get_running_urls

format_yaml_for_logging

open_in_web_browser

open_dashboard_in_web_browser

startup

Setup HTTP client for connecting to 3LC Data Service

shutdown

Perform any required cleanup before terminating the application

root

Root endpoint of the service

live

Endpoint for checking if the service is running.

get_status

Returns status of the service

get_last_lru_stats

status

Returns status of the service

create_litestar_app

Data

Data

Description

last_lru_stats

T

API

class LitestarStateConstants

Constants for the Litestar state.

HOST_IP = HostIP
OBJECT_SERVICE_RUNNING_URLS = ObjectServiceRunningsURLs
NGROK_OBJECT_SERVICE_URL = NGrokObjectServiceURL
internal_server_error_handler(
request: Request,
exception: Exception,
) Response

Catch-all for application errors.

insufficient_credits_handler(
request: Request,
exception: tlcsaas.transaction.InsufficientCredits,
) Response

Handler for insufficient credits.

timestamp_skew_handler(
request: Request,
exception: TimestampSkewException,
) Response

Handler for timestamp skew.

get_ip_addresses() list[str]
get_running_urls() list[str]
format_yaml_for_logging(
data: dict | list,
indent: int = 4,
) str
open_in_web_browser(
url: str,
) None
open_dashboard_in_web_browser(
app: Litestar,
) None
async startup(
app: Litestar,
) None

Setup HTTP client for connecting to 3LC Data Service

async shutdown(
app: Litestar,
) None

Perform any required cleanup before terminating the application

async root() Response

Root endpoint of the service

async live() Response

Endpoint for checking if the service is running.

class ObjectServiceFeatures(
/,
**data: typing.Any,
)

Bases: pydantic.BaseModel

post_external_data: bool = True
class ObjectServiceUserInfo(
/,
**data: typing.Any,
)

Bases: pydantic.BaseModel

user_id: str = None
tenant_id: str = None
user_full_name: str = None
user_email: str = None
tenant_name: str = None
class DashboardAnnotations(
/,
**data: typing.Any,
)

Bases: pydantic.BaseModel

banner_icon_url: str = <Multiline-String>
banner_background_color: str = <Multiline-String>
banner_message: str = <Multiline-String>
title_message: str = <Multiline-String>
get_status() dict[str, Any]

Returns status of the service

last_lru_stats: dict[str, Any] | None = None
get_last_lru_stats() dict[str, Any] | None
async status(
request: Request,
) dict[str, Any]

Returns status of the service

class TLCCustomLoggingMiddleware(
app: litestar.types.ASGIApp,
config: LoggingMiddlewareConfig,
)

Bases: litestar.middleware.logging.LoggingMiddleware

Custom middleware to log object service requests and responses.

Logs request and response data to loglevel.INFO, together with the time it takes to complete the request.

Initialize LoggingMiddleware.

Args: app: The next ASGI app to call. config: An instance of LoggingMiddlewareConfig.

async log_request(
scope: litestar.types.Scope,
receive: litestar.types.Receive,
) None

Record the start time and log the request data.

log_response(
scope: litestar.types.Scope,
) None

Measure elapsed time and log the response data.

log_message(
values: dict[str, Any],
) None

Log a message.

This is a copy of the superclass’ method, with special case handling of the /status endpoint, and url decoding of the path.

Parameters:

values – Extract values to log.

Returns:

None

class NGrokOutputAdaptor(
role: str,
ngrok_helper: tlccli.subcommands.ngrok_helper.NGrokHelper,
)

Helper class to format output from NGrokHelper for the Object Service.

async output_public_url(
app: Litestar,
) None
T = TypeVar(...)
create_litestar_app(
host: str,
port: int,
use_ngrok: bool,
dashboard: bool = False,
after_startup_handler: list[litestar.types.callable_types.LifespanHook] | litestar.types.callable_types.LifespanHook | None = None,
after_shutdown_handler: list[litestar.types.callable_types.LifespanHook] | litestar.types.callable_types.LifespanHook | None = None,
) Litestar