folio-org / mod-reporting

Interface to Metadb/LDP reporting databases (plug-compatible reimplementation of mod-ldp)
Apache License 2.0
0 stars 1 forks source link

mod-reporting

Copyright (C) 2023-2024 The Open Library Foundation

This software is distributed under the terms of the Apache License, Version 2.0. See the file "LICENSE" for more information.

Overview

mod-reporting is a FOLIO module that mediates access to reporting databases -- instances of either MetaDB or LDP Classic. It removes the need to deal directly with a relational database by providing a simple WSAPI that can be used by UI code such as ui-ldp.

mod-reporting is a plug-compatible replacement for mod-ldp, using the same API specification (FOLIO module descriptor, RAML file and associated JSON Schemas and examples). It provides the same interface (ldp-query) with the same semantics. As well as the machine-readable API specification, a human-readable overview is provided.

Personal data. This module does not store any personal data. See the file PERSONAL_DATA_DISCLOSURE.md for details.

Contributing. See the file CONTRIBUTING.md for details.

Compilation and installation

mod-reporting is written in Go.

Compilation is controlled by a good old-fashioned Makefile

Invocation takes a single argument, the name of a configuration file (see below).

Containerization is supported:

GitHub workflows exist to build the code and run tests, and to create a Docker container.

Configuration

Configuration file

The configuration file is written in JSON. An example can be found in etc/config.json:

{
  "logging": {
    "categories": "config,listen,path,error",
    "prefix": "",
    "timestamp": false
  },
  "listen": {
    "host": "0.0.0.0",
    "port": 12369
  }
}

Two top-level stanzas are supported:

Logging

The following categories of logging information may be emitted, depending on how the logger is configured:

Access to the FOLIO database is performed using the foliogo client library which also uses categorical logger. See its documentation for information on the categories service, session, op, auth, curl, status and response.

FOLIO services and reporting databases

In normal operation, each incoming request is serviced by reference to the Okapi instance that sent it. For development, however, it's possible to override this behaviour and have every outgoing request go to a nominated Okapi instance. This is specified by the environment variables OKAPI_URL (e.g https://folio-snapshot-okapi.dev.folio.org) and OKAPI_TENANT (e.g. diku). Authentication onto this instance is done using the values specifid by the environment variables OKAPI_USER and OKAPI_PW.

Similarly, in normal operation mod-reporting determines which underlying reporting database to connect to on the basis of the information configured in the mod-settings record with scope ui-ldp.config and key dbinfo, as managed by the "Database configuration" settings page of the Reporting app. However, these configured settings can be overridden if mod-reporting is run with all three of the following environment variables set:

Notes

Redundant field in API

In the response from /ldp/db/reports, there is a numeric element totalRecords. Note that this is a count of the number of records included in the records array -- not the total number of hits in the database. (That information is not available from PostgreSQL). The provided field is redundant, and would have been better omitted, but we retain it for backwards compatibility.

CORS problems when running locally

If running mod-reporting locally, you will likely run into CORS problems with Stripes refusing to make GET and POST requests to it because OPTIONS requests don't return the necessary Access-control-allow-origin header. To work around this, you can run a CORS-permissive HTTP proxy such as local-cors-anywhere -- which by default listens on port 8080 -- and access the running mod-reporting at http://localhost:8080/http://localhost:12369.

See also

Additional information

Issue tracker

See project MODREP at the FOLIO issue tracker.

Code of Conduct

Refer to the Wiki FOLIO Code of Conduct.

ModuleDescriptor

See the ModuleDescriptor for the interfaces that this module requires and provides, the permissions, and the additional module metadata.

API documentation

API descriptions:

Generated API documentation.

Code analysis

SonarCloud analysis.

Download and configuration

The built artifacts for this module are available. See configuration for repository access, and the Docker images for released versions and for snapshot versions.

Author

Mike Taylor, Index Data ApS. mike@indexdata.com