database

package
v0.0.0-...-c537dde Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package database manages database connectors and implementations for the Device Lease service.

Index

Constants

View Source
const DefaultPageSize = 1000

DefaultPageSize is the default page size for paginated APIs.

Variables

This section is empty.

Functions

func BuildQueryFilter

func BuildQueryFilter(ctx context.Context, filter string) (string, []interface{})

BuildQueryFilter builds a WHERE clause based on a filter string.

Parse filter from string. Assume filters are separated by "AND" based on AIP-160.

func ConnectDB

func ConnectDB(ctx context.Context, dbConfig *DatabaseConfig) (*sql.DB, error)

ConnectDB creates a connection to the database using a TCP socket.

func DecodePageToken

func DecodePageToken(ctx context.Context, token PageToken) (string, error)

DecodePageToken decodes a base64 PageToken as a string.

Types

type Client

type Client struct {
	Conn   *sql.DB
	Config *DatabaseConfig
}

type DatabaseConfig

type DatabaseConfig struct {
	DBHost string
	DBPort string
	DBName string
	DBUser string

	// Not the actual password but just the secret string used by SecretStore.
	DBPasswordSecret string

	// Database connection pool configs.
	ConnMaxLifetime time.Duration
	MaxIdleConns    int
	MaxOpenConns    int
}

type PageToken

type PageToken string

PageToken is a string containing a page token to a database query.

func EncodePageToken

func EncodePageToken(ctx context.Context, key string) PageToken

EncodePageToken encodes a string as a base64 PageToken.

Jump to

Keyboard shortcuts

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