Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make testing slow consumers easy #429

Merged
merged 2 commits into from
Nov 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmd/gosky/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ var readRepoStreamCmd = &cli.Command{
&cli.BoolFlag{
Name: "resolve-handles",
},
&cli.DurationFlag{
Name: "read-delay",
Usage: "make handling each event take at least this long (debug utility)",
},
},
ArgsUsage: `[<repo> [cursor]]`,
Action: func(cctx *cli.Context) error {
Expand Down Expand Up @@ -204,8 +208,14 @@ var readRepoStreamCmd = &cli.Command{
return h, nil
}

rr := cctx.Duration("read-delay")

rsc := &events.RepoStreamCallbacks{
RepoCommit: func(evt *comatproto.SyncSubscribeRepos_Commit) error {
if rr != 0 {
time.Sleep(rr)
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use a rate.limiter here instead and then allow a user to configure a maximum throughput? That might be a bit easier to use.

if jsonfmt {
b, err := json.Marshal(evt)
if err != nil {
Expand Down
Loading