# README

Transaction Manager

One Paragraph of the project description

Initially appeared on gist. But the page cannot open anymore so that is why I have moved it here.

Getting Started

These instructions will give you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on deploying the project on a live system.

Prerequisites

Requirements for the software and other tools to build, test and push

Installing

To use the library, you need to have go installed on your machine. You can install Go by following the instructions on the official website.

Once you have Go installed, you can install the library by running the following command

go get github.com/SimifiniiCTO/backend-core-lib/third-party/transaction-manager

Usage

To use the library, you must first initialize the client

import (
    txm "github.com/SimifiniiCTO/backend-core-lib/third-party/transaction-manager"
)

func main(){
    temporalOpts := &client.Options{
		HostPort:  "9999",
		Namespace: "test-namespace",
	}

    retryPolicy := &txm.Policy{
		RetryInitialInterval:    TemporalRetryInitialInterval,
		RetryBackoffCoefficient: TemporalBackoffCoefficient,
		MaximumInterval:         TemporalMaxRetryInterval,
		MaximumAttempts:         TemporalMaxRetryAttempts,
	}

    opts := []txm.Options{
        txm.WithClientOptions(temporalOpts),
        txm.WithInstrumentationClient(&instrumentation.Client{}),
        txm.WithLogger(log),
        txm.WithPostgres(postgresClient), // Optional 
        txm.WithMongo(mongoClient), // Optional
        txm.WithRetryPolicy(retryPolicy),
        txm.WithRpcTimeout(rpcTimeout),
        txm.WithMetricsEnabled(metricsEnabled)
        txm.WithMessageQueueClient(messageQueueClient) // Optional
    }

    txmClient, err := txm.New(opts...)
    if err != nil {
        ...
    }
}

Running the tests

Explain how to run the automated tests for this system

Sample Tests

Explain what these tests test and why

Give an example

Style test

Checks if the best practices and the right coding style has been used.

Give an example

Deployment

Add additional notes to deploy this on a live system

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use Semantic Versioning for versioning. For the versions available, see the tags on this repository.

Authors

  • Billie Thompson - Provided README Template - PurpleBooth

See also the list of contributors who participated in this project.

License

This project is licensed under the CC0 1.0 Universal Creative Commons License - see the LICENSE.md file for details

Acknowledgments

  • Hat tip to anyone whose code is used
  • Inspiration
  • etc

# Functions

Instantiates a new client.
NewNamespaceClient creates an instance of a namespace client, to manage lifecycle of namespaces.
It creates a new instance of the TransactionManager struct and returns it.
Instantiates a new worker.
WithClientOptions defines the options to use when connecting to the database.
The function returns a function that takes a TransactionManager pointer and sets its instrumentation client to the provided one.
The function returns a function that takes a TransactionManager pointer and sets its logger to the provided zap logger.
This function returns a function that takes a TransactionManager pointer and sets its message queue client to the provided client.
The function returns a function that takes a TransactionManager pointer and enables or disables metrics based on a boolean input.
The function returns a closure that takes a TransactionManager pointer and sets its mongoConn field to the provided mongo.Client pointer.
The function returns a function that takes a TransactionManager pointer and sets its Postgres client field to the provided client.
The function returns a function that takes a TransactionManager and sets its retry policy to the provided policy.
The function returns a function that takes a TransactionManager pointer and sets its RPC timeout to the specified duration.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Policy outlines retry policies necessary for workflow and downstream service calls.
`TransactionManager` is the single struct by which we manage and initiate all distributed transactions within the service.

# Interfaces

No description provided by the author

# Type aliases

Option is a function that takes a TransactionManager pointer and sets some option on it.