Skip to content

v4.0.0

Choose a tag to compare

@m110 m110 released this 25 Aug 15:08
· 3 commits to master since this release

Major version bump (v4)

Breaking changes

Schema & Offsets adapters interfaces

  • Reworked the SchemaAdapter and OffsetsAdapter interfaces (Breaking change -> will bump the major to v4).
    • We had a few instances where some details have been missing from one of the interface methods. It makes it difficult to extend this library with new features, as each will require a major version bump, and we want to avoid it if possible.
    • To mitigate this, we're moving to a params struct passed to the methods instead of raw arguments. It adds some verbosity but allows extending the params if needed with no breaking changes to the library.
    • The methods now also return errors.

Migration: if you don't use a custom schema/offsets adapter, you don't need to do anything. If you do, change the methods to implement the new interfaces. Use values from the params argument and return errors.

Beginner accepted in place of *sql.DB

watermill-sql now supports any SQL connection, not just *sql.DB. For example, you can use pgx handle and transactions.

Migration: You need to wrap your db connection with a new constructor when passing it to NewSubscriber and NewPublisher: sql.BeginnerFromStdSQL(db)

See the example:

	subscriber, err := sql.NewSubscriber(
		sql.BeginnerFromStdSQL(db),
		sql.SubscriberConfig{
			SchemaAdapter:    sql.DefaultMySQLSchema{},
			OffsetsAdapter:   sql.DefaultMySQLOffsetsAdapter{},
			InitializeSchema: true,
		},
		logger,
	)

	publisher, err := sql.NewPublisher(
		sql.BeginnerFromStdSQL(db),
		sql.PublisherConfig{
			SchemaAdapter: sql.DefaultMySQLSchema{},
		},
		logger,
	)

What's Changed

New Contributors

Full Changelog: v3.1.0...v4.0.0