apirtinit

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2024 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package apirtinit contains internal implementation for RTInitialize

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MobrouteRuntime

type MobrouteRuntime struct {
	MobsqlRuntime *mobsql.MobsqlRuntime
	DB            *sqlx.DB
}

MobrouteRuntime contains the database connection and the git.sr.ht/~mil/mobsql.MobsqlRuntime. This may also contain other properties relevant for global Mobroute operation in the future. The database connection points to a local SQLite file and the Mobsql runtime connection generally will reference the same DB file. The reason for storing the DB separately from Mobsql's runtime (and not just using Mobsql's own DB connection) is that Mobroute itself uses the DB field for RO operations only; all RW functionality happens through Mobsql / the MobsqlRuntime.

This struct is passed to all other library functions and should be initialized by using RTInitialize.

func RTInitialize

func RTInitialize(params *MobrouteRuntimeConfig) (*MobrouteRuntime, error)

RTInitialize initializes a new MobrouteRuntime which contains a passthrough to the git.sr.ht/~mil/mobsql.MobsqlRuntime, the SQLite DB connection, and some additional metadata. On initialization this function: bootstraps the DB (e.g. creating SQL tables, views, indexes), create Mobsql connection / initialization, and fetches the Mobility Database CSV and imports to DB.

All other library functionality depend on the returned MobrouteRuntime.

type MobrouteRuntimeConfig

type MobrouteRuntimeConfig struct {
	MobsqlRuntimeConfig mobsql.RuntimeConfig `json:"mobsql_runtime_config"`
	Logger              *log.Logger          `json:"-"`
	LogInfo             bool                 `json:"log_info"`
	LogWarn             bool                 `json:"log_warn"`
	LogDebug            bool                 `json:"log_debug"`
}

MobrouteRuntimeConfig contains the the underlying git.sr.ht/~mil/mobsql/MobsqlRuntimeConfig and potentially in the future some other Mobroute-specific properties for the common DB connection and Mobroute params config. This is used by RTInitialize and you can use this struct to configure various properties around logging and Mobsql initialization.

The Logger field can be very helpful in redirecting log messages to see more verbose output for functions then just the returned type / error.

An empty configuration (e.g. nil values) for all properties is entirely valid and defaults will be configured in that case.

type MobsqlRuntimeConfig

type MobsqlRuntimeConfig = mobsql.RuntimeConfig

MobsqlRuntimeConfig alias for git.sr.ht/~mil/mobsql.RuntimeConfig. In most normal cases where this is seen in MobrouteRuntimeConfig this should just be left as nil. The case when it makes sense to configure underlying the underlying Mobsql config is if you are interested in changing logging and other underlying schema properties for Mobsql. See underlying origin git.sr.ht/~mil/mobsql.RuntimeConfig doc for more details.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL