PCLT-DB-0.1.1: An addon to PCLT package: enchance PCLT catalog with PostgreSQL powers.

Database.PCLT.UpdatableCatalog

Description

A module around a thread that considers updating catalog, when commanded to do so.

Synopsis

Documentation

data PCLTRawCatalog__Database_PCLT_UpdatableCatalog Source

This type is a special instance of HasStaticRawPCLTs - it accumulates all other instances of HasStaticRawPCLTs from the whole PCLT-DB package, and also from PCLT package.

This instance is best to be used as an intial input for the catalog formation in your applications.

catalogUpdatorIteration :: Connection -> PCLT_CatalogID -> (PCLT_Catalog -> CatalogUpdateFromDBErrors -> IO ()) -> PCLT_Catalog -> IO (Maybe PCLT_Catalog)Source

Input contains current catalog version. If the update failed and returned no new catalog version, or if update isn't needed, then current catalog version is returned.

If there appeared any errors, they get acted with. The action is specified by user.

runCatalogUpdatorService :: HasStaticRawPCLTs a => (PCLT_CatalogID, PCLT_InnerConfig, a) -> (Connection, DisconnectDBConnWhenFinished_shouldwe) -> (PCLT_Catalog -> CatalogUpdateFromDBErrors -> IO ()) -> Chan MakeIterationAndContinueCycle_shouldwe -> IO (MVar PCLT_Catalog, ThreadId)Source

The first version of catalog, that service forms is always from nonDB source, but is from specified in the first triple (catalog ID, config and some instance of HasStaticRawPCLTs). That way, even if DB never responds, service always has at least this version of catalog available.

In the 3rd argument user specifies action, that has a role of errors processor (reporter).

The 4th argument is a Chan, which this service listens to.

  • If True comes, service makes iteration (reads catalog from DB if needed, and writes new version into the MVar), and continues cycle.
  • If False comes, service stops.

The returned MVar is created by service itself and is a container, where it keeps last version of catalog.

runCatalogUpdatorService_wDefaultInitial :: PCLT_CatalogID -> (Connection, DisconnectDBConnWhenFinished_shouldwe) -> (PCLT_Catalog -> CatalogUpdateFromDBErrors -> IO ()) -> Chan MakeIterationAndContinueCycle_shouldwe -> IO (MVar PCLT_Catalog, ThreadId)Source

Wrapper around runCatalogUpdatorService. The service starts from default config (defaultPCLTInnerConfig) and default set of templates (PCLTRawCatalog__Database_PCLT_UpdatableCatalog). But updates from DB orienting on given PCLT_CatalogID, which may be different set of templates and different config.