Skip to content

Add an equivalent of river.WorkFunc for Ruby - #1486

Merged
brandur merged 1 commit into
masterfrom
brandur-ruby-work-func
Oct 10, 2026
Merged

brandur merged 1 commit into
masterfrom
brandur-ruby-work-func

Conversation

@brandur

@brandur brandur commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Just noticed while doing a manual review on docs changes that Ruby
doesn't have an equivalent to Go's river.WorkFunc whereas the rest of
the languages do.

Here, let workers.add take a kind and closure:

workers.add(:send_message) do |job|
  puts "Message: #{job.args.fetch("message")}"
end

Insertions would have to come from another language or use JobArgsHash:

client.insert River::JobArgsHash.new(:send_message, message: "Hello!")

This admittedly isn't a huge improvement, but I think it's probably
worth doing just because both Rust and TypeScript have something
extremely similar. This puts all languages on equal footing.

Here, add one in. It's arguable as to whether it adds all that much
compared to a normal class which is already pretty terse, but it does
let you

@brandur
brandur requested a review from bgentry October 9, 2026 19:04
@brandur

brandur commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@bgentry This one's not a big deal, but just happened to notice it while manual inspecting docs.

@bgentry bgentry left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Huh, not sure if this can some how be conformance tested but it'd be nice to ensure we have comparable feature sets across the ports.

Just noticed while doing a manual review on docs changes that Ruby
doesn't have an equivalent to Go's `river.WorkFunc` whereas the rest of
the languages do.

Here, let `workers.add` take a kind and closure:

    workers.add(:send_message) do |job|
      puts "Message: #{job.args.fetch("message")}"
    end

Insertions would have to come from another language or use JobArgsHash:

    client.insert River::JobArgsHash.new(:send_message, message: "Hello!")

This admittedly isn't a huge improvement, but I think it's probably
worth doing just because both Rust and TypeScript have something
extremely similar. This puts all languages on equal footing.

Here, add one in. It's arguable as to whether it adds all that much
compared to a normal class which is already pretty terse, but it does
let you
@brandur
brandur force-pushed the brandur-ruby-work-func branch from 25d412e to a234416 Compare October 10, 2026 04:24
@brandur

brandur commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

thx!

Huh, not sure if this can some how be conformance tested but it'd be nice to ensure we have comparable feature sets across the ports.

Yeah, maybe something we can figure out. That said, I think once we get a couple passes in to pick up any of these omissions, they're pretty unlikely to regress.

@brandur
brandur merged commit 27df646 into master Oct 10, 2026
33 checks passed
@brandur
brandur deleted the brandur-ruby-work-func branch October 10, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants