Skip to content

go-core-stack/core

Repository files navigation

Core Infra

This repository contains modules providing the core infra for other projects with many required functionalities, some of which are high lighted as follows

Errors package

Errors package available out of the box in golang does not provide options to carry information regarding error codes, this typically becomes handy while comparing and checking for error types, rather than comparing error message strings returned by different functions, enabling writing more sturdy, reliable and quality code Includes most common supported error types like

  • Already Exists / duplicate entry
  • Entry Not Found
  • Invalid Argument
  • and more, while defaulting to unknown error type, while code is not set

Database Abstraction Layer (db/)

Database abstraction layer providing generic, type-safe database operations with MongoDB as the primary implementation. Features include:

  • Generic interfaces (StoreClient → Store → StoreCollection)
  • Change stream monitoring with callbacks
  • Event logging with audit support
  • High availability configuration (majority write concern, journaling)
  • Error code translation for consistent error handling
  • Thread-safe source identifier tracking for multi-replica deployments

See db/README.md for detailed documentation.

Table Abstraction Layer (table/)

High-level table abstractions built on the database layer, providing:

  • Table[K, E]: Type-safe direct database access with reconciler integration
  • CachedTable[K, E]: In-memory cached table with automatic synchronization
  • Go generics for compile-time type safety
  • Automatic cache updates via change stream callbacks
  • Thread-safe concurrent access with read-write locks
  • Write-through caching with eventual consistency

See table/README.md for detailed documentation.

Reconciler infra

Reconciler infra is influenced by kubernetes controller and manager infrastructure. However, unlike kubernetes here this infra is responsible for providing Reconciliation engine while working with any data store instead of Kubernetes CRDs. Where currently it supports mongodb client based data store as well as a local cached datastore based reconciliation logics

Additionally, infra has pipelines support maintaining separate pipelines for individual clients allowing capability of requeuing the entry to be processed again after some time or observed error while processing it, so requeue for processing again immediately.

Sync Package

Sync infra provides logic for synchronization between processes and/or microservices. Providing a base logic layer allowing seemslessly working between multiple microservices working in tandom. This package provides following support

Owner Infra

Owner infra is the base requirement for anyone using sync package, where they initialize the owner infra with datastore to be used along with the owner name for the reference, where any sync construct provided will be using this owner name as the reference for managing sync constructs while ensuring cleanup of sync objects when the corresponding owner object is deleted either due to shutdown or timeout/agedout by participating processes.

Here this also ensures appending an autogenerated ID along with the owner name providing capability to seemlessly work with multiple replicas of same microservice and handling restart scenarios (graceful as well as non-graceful)

Lock infra

Lock infra provides sync construct equivalent of mutex but capability of working across processes as functionality is provided out of mongodb backed datastore. This allows holding and managing a lock across processes while possibly running on different physical servers (kubernetes nodes)

Provider and Observer infra

This infra is motivated with providing capability of working with service providers possibly comming from multiple replicas or processes and observers with a need to react on availability of first provider or unavailability of last provider to trigger certain logics, while moving from 1 provider to multiple are typically handled due to a load balancer capabilities provided by kubernetes or equivalent systems

SMTP Wrapper

This is a wrapper over an above standard net/smtp providing client and other constructs to work with emails based triggers and communication over emails while device compatible smtp email account is provided

About

Repo Holding core infrastructure code

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •