work
A compact library for tracking and committing atomic changes to your entities.
What is it?
work
does the heavy lifting of tracking changes that your application makes
to entities within a particular operation. This is accomplished by using what we
refer to as a "work unit", which is essentially an implementation of the
Unit Of Work pattern popularized by Martin Fowler. With work units,
you no longer need to write any code to track, apply, or rollback changes
atomically in your application. This lets you focus on just writing the code
that handles changes when they happen.
Why use it?
- easier management of changes to your entities.
- automatic rollback of changes when chaos ensues.
- centralization of save and rollback functionality.
- reduced overhead when applying changes.
- decoupling of code triggering changes from code that persists the changes.
- production-ready logs and metrics.
- works with your existing persistence layer.
- automatic and configurable retries.
For SQL datastores, also enjoy:
- one transaction, one connection per unit.
- consolidates persistence operations into three operations, regardless of the amount of entity changes.
- shorter transaction times.
- transaction is opened only once the unit is ready to be saved.
- transaction only remains open as long as it takes for the unit to be saved.
- proper threading of
context.Context
withdatabase/sql
.
Release information
4.0.0-beta
- Introduce
unit
package for aliasing.- Reduces API footprint.
- Often "flows" better.
- Introduce retries and related configuration.
- Reconsolidate data mappers abstractions into single
DataMapper
interface. - Introduce
MapperContext
. - Alter
Save
to becontext.Context
aware. - Refactor
work.NewUnit
to dynamically choose which type of work unit to create based on provided options. - Reconsolidate uniter functionality.
3.2.0
- Introduce lifecycle actions.
- Introduce concurrency support.
3.0.0
- Introduce support for Go modules.
2.x.x
- NO LONGER SUPPORTED.
1.x.x
- NO LONGER SUPPORTED.
Versions
1.x.x
and2.x.x
are no longer supported. Please upgrade to3.x.x+
to receive the latest and greatest features, such as lifecycle actions and concurrency support!
Dependancy Information
As of v3.0.0
, the project utilizes modules.
Prior to v3.0.0
, the project utilized dep
for dependency management.
In order to transition to modules gracefully, we adhered to the best practice recommendations authored by the Golang team.
Contribute
Want to lend us a hand? Check out our guidelines for contributing.
License
We are rocking an Apache 2.0 license for this project.
Code of Conduct
Please check out our code of conduct to get up to speed how we do things.