apptypes

package
v0.9.0 Latest Latest
Warning

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

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

Documentation

Overview

Package apptypes contains internal types used by the application across other packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComputedTable

type ComputedTable struct {
	Name          string
	Doc           string
	SQLSelectView string
	SQLInit       string
	SQLDeinit     string
	FeedPair      bool
	CacheOnTables []string
	TableSpec     TableSpec
}

ComputedTable represents a computed table specification

type DType added in v0.9.0

type DType int

DType represents a type corresponding to an underlying SQLite type

const DTypeEnum DType = 4

DTypeEnum represents an enum in SQLLite (currently stored as type int)

const DTypeID DType = 3

DTypeID represents an ID in SQLite, (currently correlates to type `text` however this may change in the future when a more applicable ID type is found).

const DTypeInt DType = 0

DTypeInt represents an integer in SQLite (correlates to type `int`)

const DTypeReal DType = 1

DTypeReal represents an real in SQLite (correlates to type `real`)

const DTypeText DType = 2

DTypeText represents text in SQLite (correlates to type `text`)

type FeedOpResult added in v0.6.0

type FeedOpResult struct {
	Operation string `json:"operation"` // Name of operation (compute/purge/load)
	Success   bool   `json:"success"`   // Whether the operation was successful
	FeedIDs   []int  `json:"feed_ids"`  // Array of feed IDs matched / performed against
}

FeedOpResult represents the result of a compute, purge, or loadmdbgtfs, or loadcustomgtfs request. This type exposes whether the operation was successful and the effected feedIDs.

In the future this type may be augmented with additional metadata related to the response status.

type LoadColumn

type LoadColumn struct {
	Column        string
	DType         DType
	Required      bool
	PKey          bool
	Check         string
	Enum          []int
	ConversionSQL string
}

LoadColumn represents a single column to load for a TableSpec.

type LoadSchema

type LoadSchema struct {
	TablesGTFS                  []LoadTable
	TableSystemTracking         TableSpec
	TableSystemGTFSSourceMDB    TableSpec
	TableSystemGTFSSourceCustom TableSpec
	ViewsSystem                 []View
}

LoadSchema holds the core 'database schema' for the entire SQLite DB. This tracks both GTFS tables in TablesGTFS, a tracking table, MDB & Custom source tracking tables, and system views.

type LoadTable

type LoadTable struct {
	File      string
	Doc       string
	TableSpec TableSpec
}

LoadTable represents a table to be loaded per TableSpec to SQLite backed by an associated file.

type MobsqlRuntime

type MobsqlRuntime struct {
	DB                      *sqlx.DB     // Connection to local SQLite DB
	MobilityDBCatalogCSVURI string       // URI (file:// or http://) of Mobility Database Catalog CSV URI (use load custom GTFS), default Mobility DB bit.ly
	Schema                  LoadSchema   // Base GTFS and core application schema
	SchemaExtra             *SchemaExtra // Extra SQL schema configuration (user-provided views & computed tables config)
}

MobsqlRuntime holds the database connection and some global configuration properties. All public functionality in the library depends on this struct and it may be created using [InitializeRuntime].

type RuntimeConfig

type RuntimeConfig struct {
	MobilityDBCatalogCSVURI string `json:"mdb_csv,omitempty"`   // URI (file:// or http://) of Mobility Database Catalog CSV URI (use load custom GTFS), default Mobility DB bit.ly
	SQLiteDBPath            string `json:"sqlite_db,omitempty"` // Filesystem path for the SQLite DB, if "" uses default of ~/.cache/mobsql/sqlite.db
	LogInfo                 bool   `json:"log_info,omitempty"`  // Whether to enable info messages
	LogWarn                 bool   `json:"log_warn,omitempty"`  // Whether to enable warning messages
	LogDebug                bool   `json:"log_debug,omitempty"` // Whether to enable debug messages

	Logger      *log.Logger  `json:"-"` // Custom *log.Logger to use instead of default stderr logging
	SchemaExtra *SchemaExtra `json:"-"` // Extra SQL schema configuration (views & computed tables config)
}

RuntimeConfig contains the configuration for the library usage used in creating a MobsqlRuntime by [InitializeRuntime]. These are global properties defined one-off upon initialization.

All properties if unset will just use defaults and specifying values in this struct is an advanced-usage pattern.

type SchemaExtra

type SchemaExtra struct {
	InitExec       string          // Arbitrary SQL to execute at initialization (can be used for pragmas etc.)
	TablesComputed []ComputedTable // Computed table specifications to create
	Views          []View          // SQL views to create
}

SchemaExtra represents extra arbitrary SQL views & computed tables that may build upon the feed GTFS tables.

type TableSpec

type TableSpec struct {
	Table     string       // Table name
	UniqueSet []string     // Optional UniqueSet to create, specify fields / columns
	Columns   []LoadColumn // Columns to load
	Indexes   [][]string   // Indexes to be created inner array is fields to index
	Optional  bool         // Non-fatal & simply skip table if missing
}

TableSpec specifies a table to be created in SQLite with the columns indexes, and unique specs as indicated.

type View

type View struct {
	Name               string
	SQLCreateStatement string
	Doc                string
}

View represents a SQLite view as defined by the SQLCreateStatement. The SQLCreateStatement should be in the form of a select query - for example `select 1` would be valid. From application logic this is always created via `create view foo as {SQLCREATESTATEMENT}`; so note do not add the create view bit yourself.

Jump to

Keyboard shortcuts

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