refactor02 #10

Merged
nex merged 30 commits from oddlid/sensebot-go:refactor02 into dev 2026-05-20 09:05:20 +01:00
Contributor

Linter fixes, TODOs and other refactoring.

Linter fixes, TODOs and other refactoring.
Context aware channel operations.
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
2712a30ee2
Also added some low hanging test cases in buttons/.
Context aware fuse implemenntation
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
7ef516601d
oddlid force-pushed refactor02 from 7ef516601d
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
to 33f8763fbc
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
2026-03-30 10:27:26 +01:00
Compare
Added filtering of joined members in getHomeServersInRoom
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
48b36f6fc1
Tested out maps.DeleteFunc for filtering in getHomeServersInRoom
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
53175e3437
Cache result of len where called repeatedly on the same value
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
1fd54b4411
Added package worker
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
4dfc33bceb
A generic implementation of fan-out/fan-in that I think can be
(re)usable in this project.
Updated .gitignore
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
495fa96dac
Extended worker package, and wrote tests.
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
8838bb0cd0
Also tried debugging paginator buttons, but no luck.
s/Get/New/ for worker function names
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
30fa7d3d53
Made workers buffered.
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
e31b351cae
Also tried to pass a new context to cleanup functions, to give it a
chance to complete on shutdown, but it's not enough.
Might use a top level WaitGroup for this.
Top-level WaitGroup + leak fix.
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
5dae0c3791
- Added a WaitGroup and associated methods to the Client struct, which
  is used to spawn and keep track of all other goroutines, ensuring
  they're all completed before shutdown.
- Found a way to unregister event handlers, so the leak in buttons.Menu
  is now gone.
More worker stuff
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
3fb6279019
Made CommandContext.Arguments private
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
c5e1577bc6
@ -0,0 +15,4 @@
// example in the errgroup docs struck me as bound to deadlock, due to unbuffered
// channels and calling Wait before consuming the channel. And I was right.
func Test_MenuPopulateWithErrGroupConcept(t *testing.T) {
t.Skip("Manual test, disabled")
Owner

If this test is just unconditionally skipped it should probably just not be included

If this test is just unconditionally skipped it should probably just not be included
Author
Contributor

Yes, there's a lot I'm intending to remove before merge, like this one. Just keeping it temporarily as notes to self, so I don't forget what I was thinking.
I tend to write tests just to figure out concepts, and then delete them when I've either implemented it properly, or just moved on to another solution.
But good that you remind me! There will for sure be more like this, so just keep commenting :)

Yes, there's a lot I'm intending to remove before merge, like this one. Just keeping it temporarily as notes to self, so I don't forget what I was thinking. I tend to write tests just to figure out concepts, and then delete them when I've either implemented it properly, or just moved on to another solution. But good that you remind me! There will for sure be more like this, so just keep commenting :)
nex marked this conversation as resolved
@ -67,0 +68,4 @@
// the button order gets jumbled after the first paging operation.
// After a paging operation in EX, one can observe the buttons being out of order directly after a
// click, but they sort and rearrange themselves back in order quickly.
// I have no clue as to why this is.
Owner

I'm pretty sure gomuks sorts them lexicographically, element tries to respect the order of addition but doesn't do very well with how much the timeline shifts

In the future, something like Bot buttons & conversations will provide a better interface

I'm pretty sure gomuks sorts them lexicographically, element tries to respect the order of addition but doesn't do very well with how much the timeline shifts In the future, something like [Bot buttons & conversations](https://github.com/matrix-org/matrix-spec-proposals/pull/4139) will provide a better interface
nex marked this conversation as resolved
Removed some unused tests
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
609a490fac
Added dynamic event registration for paginator
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
7455c20620
oddlid changed title from WIP: refactor02 to refactor02 2026-04-14 08:42:37 +01:00
nex requested changes 2026-05-20 08:28:18 +01:00
Dismissed
nex left a comment

Looks good, thanks for squashing those TODOs. Just a few nits

Looks good, thanks for squashing those TODOs. Just a few nits
@ -68,6 +70,41 @@ func (bot *Client) CloseDB() error {
return bot.db.Close()
}
func (bot *Client) Go(f func()) {
Owner

nit: I know this is basically an alias for bot.wg.Go, but naming the function Goroutine or ToGoroutine etc might be more intuitive or otherwise semantically clear, such as:

- foo.Bot.Go(xyz)
+ foo.Bot.ToGoroutine(xyz)
nit: I know this is basically an alias for `bot.wg.Go`, but naming the function `Goroutine` or `ToGoroutine` etc might be more intuitive or otherwise semantically clear, such as: ```diff - foo.Bot.Go(xyz) + foo.Bot.ToGoroutine(xyz) ```
nex marked this conversation as resolved
@ -0,0 +41,4 @@
}
}
// NewGeneratorFromIterator is just like NewGeneratorFromList, exceppt it takes an iterator
Owner

exceppt -> except

`exceppt` -> `except`
nex marked this conversation as resolved
@ -0,0 +107,4 @@
}
// NewWaitGroupWorker is nearly identical to NewDefaultWorker, except it uses the passed
// WaitGroup to spawn goroutines, so that the caller may call wg.Wait() in the end.
Owner

Personally, I'd just make NewDefaultWorker take a nilable sync.WaitGroup, creating its own if the passed one is nil. Alternatively, making NewDefaultWorker call NewWaitGroupWorker with its own WaitGroup, to improve code re-use surface, and reduce the amount of duplicated logic

Personally, I'd just make `NewDefaultWorker` take a `nil`able `sync.WaitGroup`, creating its own if the passed one is `nil`. Alternatively, making `NewDefaultWorker` call `NewWaitGroupWorker` with its own WaitGroup, to improve code re-use surface, and reduce the amount of duplicated logic
nex marked this conversation as resolved
Fixups suggested by Nexy:
All checks were successful
Build docker on push / docker (pull_request) Has been skipped
7149599817
- Rename Client.Go -> Client.RunTask
- Fix typo in a comment
- Delete NewDefaultWorker, as it's currently not used
nex approved these changes 2026-05-20 09:05:04 +01:00
nex left a comment

Thank you!

Thank you!
nex merged commit da316f3405 into dev 2026-05-20 09:05:20 +01:00
nex referenced this pull request from a commit 2026-05-20 09:05:21 +01:00
Sign in to join this conversation.
No reviewers
nex
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nex/sensebot-go!10
No description provided.