Skip to content

donzuub/pms-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PMS Tooling

Table of Contents

Introduction

This repository contains two CLI tools written in Go for integrating and processing data between Firestore and SQLite. The first tool (db_gen.go) is responsible for watching Firestore for new changes and storing them in an SQLite database. The second tool (pms_gen.go) fetches, processes, and transforms data from the SQLite database and writes the transformed data to JSON files.

db_gen.go

Installation

To install the dependencies and build the db_gen CLI tool, follow these steps:

  1. Install Dependencies

    go get -u cloud.google.com/go/firestore
    go get -u github.com/mattn/go-sqlite3
    go get -u github.com/spf13/viper
    go get -u google.golang.org/api/iterator
    go get -u google.golang.org/api/option
  2. Build the CLI

    go build -o db_gen db_gen.go

Configuration

The db_gen CLI tool requires a configuration file named .zuubrc in your home directory. This file should be in YAML format and contain the following keys:

environment: "STAGE" # or "PROD"
interval_ms: 5000

Additionally, set the following environment variables:

  • GCP_STAGE_CREDS: Path to the Firestore credentials file for the staging environment.
  • GCP_PROD_CREDS: Path to the Firestore credentials file for the production environment.

Usage

Run the db_gen CLI tool as follows:

./db_gen --debug=false

This tool performs the following tasks:

  • Loads configuration from .zuubrc.
  • Connects to Firestore and SQLite.
  • Watches Firestore for new changes and stores them in SQLite.
  • Processes Firestore documents and tracks acknowledged documents.

Command-Line Flags

  • --debug: Enables debug mode to log raw Firestore documents. Default is false.

pms_gen.go

Installation

To install the dependencies and build the pms_gen CLI tool, follow these steps:

  1. Install Dependencies

    go get -u github.com/google/uuid
    go get -u github.com/mattn/go-sqlite3
  2. Build the CLI

    go build -o pms_gen pms_gen.go

Usage

Run the pms_gen CLI tool as follows:

./pms_gen

This tool performs the following tasks:

  • Connects to the SQLite database.
  • Fetches and processes data for a list of bot IDs.
  • Transforms the fetched data and writes it to JSON files.

Output

The transformed data is written to the data directory in JSON files named after each bot ID.

Common Errors and Troubleshooting

  • Error reading config file: Ensure the .zuubrc file exists in your home directory and is correctly formatted.
  • Failed to create Firestore client: Verify that the credentials file path is correct and the file is accessible.
  • Failed to connect to SQLite: Ensure the SQLite database file path is correct and the file is accessible.
  • Error fetching data for botid: Check the bot ID and ensure that there are records in the SQLite database with the specified bot ID.

If you encounter any other issues, please refer to the logs for detailed error messages and stack traces.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages