Commit Graph

190 Commits

Author SHA1 Message Date
James Mills 996ff9549f
Update CHANGELOG for v0.1.21 2023-04-23 12:02:49 +10:00
James Mills 14a6294f27 Fix off-by-one error in Queue.ForEach() (#41)
Fixes #40 and salty.im#24 🤞

Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/prologic/msgbus/pulls/41
Reviewed-by: xuu <xuu@noreply@mills.io>
2023-04-23 01:59:40 +00:00
James Mills f7bc71d0d0
Fix execution of notify step in CI 2022-11-08 09:17:03 +10:00
James Mills 575b213895
Fix Drone CI syntax for trigger conditions 2022-11-08 08:38:23 +10:00
James Mills a9bf4fe8d9
Trigger CI 2022-11-08 08:23:33 +10:00
James Mills 006c37a7c2
Update CHANGELOG for v0.1.20 2022-04-18 13:08:15 +10:00
mlctrez 902d51c951 check for context cancelled errors using errors.Is (#39)
Co-authored-by: mlctrez <mlctrez@gmail.com>
Reviewed-on: https://git.mills.io/prologic/msgbus/pulls/39
Reviewed-by: James Mills <james@mills.io>
Co-authored-by: mlctrez <mlctrez@noreply@mills.io>
Co-committed-by: mlctrez <mlctrez@noreply@mills.io>
2022-04-15 18:32:05 +00:00
James Mills a421534ee1
Update CHANGELOG for v0.1.19 2022-04-05 16:09:42 +10:00
James Mills 7d7e34e753
Fix panic updating metrics when not enabled 2022-04-05 16:09:34 +10:00
James Mills 1a4f4c769c
Update CHANGELOG for v0.1.18 2022-04-05 13:00:10 +10:00
James Mills daafbf1c60 Refactor client with correct reconnecting behaviour, contexts and a clean design (#37)
Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/prologic/msgbus/pulls/37
Reviewed-by: xuu <xuu@noreply@mills.io>
2022-04-05 02:59:48 +00:00
James Mills 1f25a21e20
Update CHANGELOG for v0.1.17 2022-04-04 12:37:09 +10:00
James Mills 7f1a30c6b0 Fix a bug in client not tracking topic index when using indexing (#36)
Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/prologic/msgbus/pulls/36
2022-04-04 02:36:56 +00:00
James Mills 9e489aadfc
Update CHANGELOG for v0.1.16 2022-04-04 11:59:18 +10:00
James Mills e7f0248805 Set a unique client id per subscriber connection (#35)
Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/prologic/msgbus/pulls/35
2022-04-04 01:56:56 +00:00
James Mills 6c5e6c3184
Update CHANGELOG for v0.1.15 2022-04-04 11:16:03 +10:00
James Mills 01ab56f9b3 Fix Subscribe() deadlock (#34)
Fixes #139

This was caused by full subscriber buffers.

Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/prologic/msgbus/pulls/34
2022-04-04 01:15:49 +00:00
James Mills 6bfb669347 Add support for a write-ahead-log (WAL) to persist messages (#33)
Closes #31

Adds support for a write-ahead-log (WAL) for messages per queue/topic. This is now the new default behaviour and adds a new CLI flag `-l/--log-path` and Env var `LOG_PATH` to configure where the logs are stored.

On startup, the message bus will refill the queues with the contents of messages from persisted log files with the most recent `-Q/--max-queue-size` number of items.

That is, on startup/crash the queues/topics will always contain the same messages as if the message bus had never restarted or crashed in the first place.

This has a benefit of actually making the per-topic sequence number _actually_ monotic increasing integers and something that can be relied upon when indexing into a queue/topic for subscribers with the `-i/--index` / `Index` option.

Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/prologic/msgbus/pulls/33
2022-04-03 15:59:38 +00:00
James Mills 95505d5e2b
Update CHANGELOG for v0.1.14 2022-04-03 08:23:15 +10:00
James Mills 429361c85c Fix case for invalid Index to handle Topic resets (msgbus restarts or crashes) (#30)
Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/prologic/msgbus/pulls/30
2022-04-02 22:23:01 +00:00
James Mills 14b5443f50 Fix panic on nil message (#29)
Fixed a bug I found in `saltyd`:

```
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 2022/04/02 21:49:31 http: panic serving 10.0.2.82:50050: interface conversion: interface {} is nil, not msgbus.Message
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | goroutine 1839 [running]:
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | net/http.(*conn).serve.func1()
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/usr/local/go/src/net/http/server.go:1825 +0xbf
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | panic({0xc8c2c0, 0xc000095e60})
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/usr/local/go/src/runtime/panic.go:844 +0x258
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | git.mills.io/prologic/msgbus.(*MessageBus).Subscribe.func1({0x0?, 0x0?})
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/go/pkg/mod/git.mills.io/prologic/msgbus@v0.1.13/msgbus.go:487 +0x205
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | git.mills.io/prologic/msgbus.(*Queue).ForEach(0xc00015abe0, 0xc00043b020)
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/go/pkg/mod/git.mills.io/prologic/msgbus@v0.1.13/queue.go:126 +0x110
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | git.mills.io/prologic/msgbus.(*MessageBus).Subscribe(0xc0004fa000, {0xc0003088f0, 0xf}, {0xc0003aae05, 0x20}, {0xc0005330a8, 0x1, 0x40d987?})
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/go/pkg/mod/git.mills.io/prologic/msgbus@v0.1.13/msgbus.go:486 +0x5ad
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | git.mills.io/prologic/msgbus.(*Client).Start(0xc0000ac300)
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/go/pkg/mod/git.mills.io/prologic/msgbus@v0.1.13/msgbus.go:742 +0xb5
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | git.mills.io/prologic/msgbus.(*MessageBus).ServeHTTP(0xc0004fa000, {0x2b1ea08, 0xc0003b4000}, 0xc0002a8200)
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/go/pkg/mod/git.mills.io/prologic/msgbus@v0.1.13/msgbus.go:617 +0x758
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | go.mills.io/saltyim/internal.(*Server).initRoutes.func1({0x2b1ea08?, 0xc0003b4000?}, 0xd8732a?, {0x1d?, 0x0?, 0x0?})
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/src/internal/handlers.go:53 +0x37
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | go.mills.io/saltyim/internal.NewServer.func1.1({0x2b1ea08, 0xc0003b4000}, 0xc0003aa200?, {0xc0000ca160, 0x1, 0x1})
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/src/internal/server.go:388 +0x26d
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | github.com/julienschmidt/httprouter.(*Router).ServeHTTP(0xc00024e900, {0x2b1ea08, 0xc0003b4000}, 0xc0002a8200)
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/go/pkg/mod/github.com/julienschmidt/httprouter@v1.3.0/router.go:387 +0x82b
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | go.mills.io/saltyim/internal.(*Router).ServeHTTP(0xc44960?, {0x2b1ea08?, 0xc0003b4000?}, 0x4?)
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/src/internal/router.go:144 +0x25
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | github.com/justinas/nosurf.(*CSRFHandler).handleSuccess(...)
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/go/pkg/mod/github.com/justinas/nosurf@v1.1.1/handler.go:187
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | github.com/justinas/nosurf.(*CSRFHandler).ServeHTTP(0xc0002245a0, {0x2b1ea08, 0xc0003b4000}, 0x4?)
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/go/pkg/mod/github.com/justinas/nosurf@v1.1.1/handler.go:144 +0x5c4
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | github.com/NYTimes/gziphandler.GzipHandlerWithOpts.func1.1({0x2b1f0f8, 0xc0000ca060}, 0x4c4801?)
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/go/pkg/mod/github.com/!n!y!times/gziphandler@v1.1.1/gzip.go:338 +0x262
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | net/http.HandlerFunc.ServeHTTP(0x2?, {0x2b1f0f8?, 0xc0000ca060?}, 0xc0003d7380?)
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/usr/local/go/src/net/http/server.go:2084 +0x2f
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | github.com/unrolled/logger.(*Logger).Handler.func1({0x2b1f7e8?, 0xc0001980e0}, 0xc0002a8100)
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/go/pkg/mod/github.com/unrolled/logger@v0.0.0-20201216141554-31a3694fe979/logger.go:80 +0xf4
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | net/http.HandlerFunc.ServeHTTP(0xc0003aa226?, {0x2b1f7e8?, 0xc0001980e0?}, 0xc000188400?)
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/usr/local/go/src/net/http/server.go:2084 +0x2f
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | net/http.serverHandler.ServeHTTP({0xc00007c210?}, {0x2b1f7e8, 0xc0001980e0}, 0xc0002a8100)
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/usr/local/go/src/net/http/server.go:2916 +0x43b
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | net/http.(*conn).serve(0xc000790000, {0x2b20228, 0xc0002ab830})
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/usr/local/go/src/net/http/server.go:1966 +0x5d7
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | created by net/http.(*Server).Serve
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | 	/usr/local/go/src/net/http/server.go:3071 +0x4db
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | time="2022-04-02T21:49:52Z" level=debug msg="pong latency of 10.0.2.82:49826: 1.671603ms"
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | time="2022-04-02T21:50:20Z" level=info msg="synced store"
saltyim_saltyd.1.w8s8tw903qnj@dm3.mills.io    | [saltyd] 2022/04/02 21:50:32 (172.69.42.134) "GET /avatar/d3d52221e8da5a8ae012f4e2db0631c181f4156f0edcde5cffa25b347c7ceda8 HTTP/1.1" 304 0 108.078µs
```

Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/prologic/msgbus/pulls/29
2022-04-02 21:59:10 +00:00
James Mills 9ee8d0f867
Update CHANGELOG for v0.1.13 2022-04-03 00:59:38 +10:00
James Mills 5c065e91ed Fix a panic on close bug (#28)
Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Reviewed-on: https://git.mills.io/prologic/msgbus/pulls/28
2022-04-02 14:50:42 +00:00
James Mills 7b71102aa8 Add support for subscribers to start from an index (#26)
Closes #20

Co-authored-by: James Mills <prologic@shortcircuit.net.au>
Co-authored-by: xuu <xuu@noreply@mills.io>
Reviewed-on: https://git.mills.io/prologic/msgbus/pulls/26
2022-04-02 14:05:15 +00:00
James Mills 4bbe613486
Fix Reconnect test 2022-04-02 14:19:17 +10:00
James Mills f51416382c
Use require.NoError() to assert errors 2022-04-02 14:16:49 +10:00
James Mills 6c83501d5d
go mod tidy 2022-04-02 14:08:14 +10:00
James Mills 591284b2ed
Remove some useless files 2022-04-02 14:00:38 +10:00
James Mills 929cfd3a36
Fix response for empty topic/queue by responding with HTTP 204 No Content instead of 404 Not Found (Fixes #25) 2022-03-31 20:55:03 +10:00
James Mills a5ef82800e
Add CORS headers so bus can be accessed cross-origin 2022-03-31 12:45:29 +10:00
xuu 7181b6df1b feat: Add Content-Encoding support for brotli, gzip, and deflate (#24)
feat: Add Content-Encoding support for brotli, gzip, and deflate
Co-authored-by: Jon Lundy <jon@xuu.cc>
Reviewed-on: https://git.mills.io/prologic/msgbus/pulls/24
Co-authored-by: xuu <xuu@noreply@mills.io>
Co-committed-by: xuu <xuu@noreply@mills.io>
2022-03-29 22:03:38 +00:00
James Mills e6ab9d9c70
Revert "Don't attempt to reconenct if we're actually closign down"
This reverts commit e954f2f47f.
2022-03-29 11:30:40 +10:00
James Mills be7c8bb616
Update CHANGELOG for v0.1.12 2022-03-28 01:49:11 +10:00
James Mills 9b3fb3c82b
Fix Client API 2022-03-28 01:49:03 +10:00
James Mills a531a278cf
Update CHANGELOG for v0.1.11 2022-03-28 01:36:04 +10:00
James Mills 5c19049da3
Revert "Fix Client API"
This reverts commit 5fe134909b.
2022-03-28 01:35:53 +10:00
James Mills 5fe134909b
Fix Client API 2022-03-28 01:31:57 +10:00
James Mills e954f2f47f
Don't attempt to reconenct if we're actually closign down 2022-03-27 23:41:31 +10:00
James Mills dec84c25a7
Update CHANGELOG for v0.1.10 2022-03-27 14:47:20 +10:00
James Mills 3f72ec8444
Partially unrevert 6a840a2 2022-03-27 14:47:14 +10:00
James Mills 60c7246f78
Update CHANGELOG for v0.1.9 2022-03-27 13:00:43 +10:00
James Mills 6a840a26b4
Revert "change gorilla/websocket to nhooyr.io/websocket"
This reverts commit ec8dbec632.
2022-03-27 12:42:56 +10:00
James Mills 3502f7b242 Merge pull request 'change gorilla/websocket to nhooyr.io/websocket' (#18) from nilsocket/msgbus:master into master
Reviewed-on: https://git.mills.io/prologic/msgbus/pulls/18
2022-03-26 23:42:53 +00:00
nilsocket ec8dbec632
change gorilla/websocket to nhooyr.io/websocket 2022-03-26 23:15:34 +05:30
James Mills 9e1d03846e
Fix client spport for wasm by partially migrating from gorilla/websocket to nhooyr.io/websocket (See #17) 2022-03-25 22:35:28 +10:00
James Mills 2461f0a973
Fix version test 2022-03-25 22:33:50 +10:00
James Mills 10968c4133
Fix version test 2022-03-25 22:20:40 +10:00
James Mills c4c1ed17f8
Update CHANGELOG for v0.1.8 2022-03-25 11:37:41 +10:00
James Mills 09d2e16ed2
Add Access-Control-Allow-Origin: * to all responses 2022-03-25 11:27:23 +10:00
James Mills 152a7664bd
Improve the msgbusd cli flag and env var handling 2022-03-21 10:10:22 +10:00