Closed jbeemster closed 1 year ago
@matus-tomlein @paulboocock any issues with merging this in? I can then take a stab at updating the docs to reflect these changes - I believe the release notes above cover the main themes and tbh most of the recommended API usage should stay the same even with all these changes.
The current flat structure of the tracker means that irrespective we always import all the storage implementation libraries. This PR does some much needed cleanup and moves to a
pkg
structure so that the actual implementations of the interface need to be imported explicitly which removes the dependency on, mainly,sqlite3
(one of the more common forking reasons I have seen).The API doesn't drastically change though it is breaking in one place.
The Emitter has a new function
RequireStorage
instead ofOptionStorage
as it must always be set now. The user must also either:pkg/storage/storageiface
interface OR;Several structures that likely should not be used directly in the Public API have also been moved to the
pkg
structure and individually packaged to allow for this implementation. Hence name of branch is to set this as v3.0.0 given number of breaking changes.This is the better way to build these sorts of libraries and makes it much more extensible for new implementations.
Release notes (example)
This is a major upgrade to the tracker with several breaking API changes. The main focus in this release has been to convert and move to a modular package structure. This lets us remove erroneous dependencies (like
sqlite3
if we are using thememory
storage implementation) but equally this is ensuring that only the required dependencies for the implementation are being brought in as the packages now need to be explicitly pulled.Golang Version Changes
With this release we are now testing against Golang v1.19, 1.18 and 1.17. Versions older than this are not guaranteed to work anymore. Please let us know if you need the Tracker to work against older versions in an issue and we can consider investigating this.
API Changes
tracker.InitPayload()
: ThePayload
struct now cannot be imported fromtracker
and instead needs to be imported frompkg/payload
to be initialized. The constructor has been renamed fromInitPayload
->Init
within this package.tracker.InitStorageMemory()
: TheStorageMemory
implementation has been moved fromtracker
topkg/storage/memory
. The constructor has been renamed fromInitStorageMemory
->Init
within this package.tracker.InitStorageSQLite3()
: TheStorageSQLite3
implementation has been moved fromtracker
topkg/storage/sqlite3
. The constructor has been renamed fromInitStorageSQLite3
->Init
within this package.tracker.Storage
: For those that were providing a custom Storage layer implementation the interface now lives inpkg/storage/storageiface
and contains theStorage
interface andEventRow
struct.In the core
tracker
module the only interface change left is in theEmitter
whereOptionStorage
andOptionDbName
have been removed. You must now always provide aStorage
implementation to theEmitter
by:RequireStorage
function in the EmitterAs an example you can look at the below:
Other API moves
All helper functions used in the library have been moved from
tracker
topkg/common
. These were always intended for internal only usage so apologies if something you depend on has been moved!