Skip to content

Create a ruby worker job for RISC notifications (LG-4972)#5333

Merged
zachmargolis merged 11 commits intomainfrom
margolis-risc-ruby-worker
Aug 26, 2021
Merged

Create a ruby worker job for RISC notifications (LG-4972)#5333
zachmargolis merged 11 commits intomainfrom
margolis-risc-ruby-worker

Conversation

@zachmargolis
Copy link
Contributor

  • Also clean up old eventbridge code (LG-4974)

Does not include rate limiting by destination, that's tracked by LG-4973

- Also clean up old eventbridge code (LG-4974)
class RiscDeliveryJob < ApplicationJob
queue_as :low

retry_on Faraday::TimeoutError, Faraday::ConnectionFailed, wait: :exponentially_longer
Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://edgeapi.rubyonrails.org/classes/ActiveJob/Exceptions/ClassMethods.html#method-i-retry_on

The defaults here are 5 retries, and with this exponential config will go from about 3s delay to a few minutes

I think this OK for now? open to suggestions

Copy link
Contributor

Choose a reason for hiding this comment

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

seems good to me

Copy link
Contributor

Choose a reason for hiding this comment

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

although the default retries is still zero (which I think is fine behavior for now)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

attempts: 5 is the default if I read that doc correctly?

Copy link
Contributor

Choose a reason for hiding this comment

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

ohhh, I see. I misunderstood. How does it behave with the inline job adapter? Since we won't want it retrying for minutes quite yet 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah sorry I wasn't clear. Async worker jobs get 5x retries. Inline preserves the current behavior of logging a warning and not retrying

https://github.com/18F/identity-idp/pull/5333/files#diff-0136d3b83a32c6efebf036634bad2428cef4f659538ae4d564b7b97019880795R34-R37

jwt: jwt(service_provider),
event_type: event.event_type,
issuer: service_provider.issuer,
transport: 'ruby_worker',
Copy link
Contributor Author

@zachmargolis zachmargolis Aug 24, 2021

Choose a reason for hiding this comment

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

if there was a way to infer if a job was performed inline vs in a thread, I'd be happy to use that instead of passing a string like this, I could not find one

Copy link
Contributor

Choose a reason for hiding this comment

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

we can call queue_adapter within the job

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Winner! 03917be

@@ -1,4 +0,0 @@
module PushNotification
class PushNotificationError < StandardError
Copy link
Contributor Author

@zachmargolis zachmargolis Aug 24, 2021

Choose a reason for hiding this comment

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

I forgot why we had this, it's unused, so it's gone now

'Accept' => 'application/json',
'Content-Type' => 'application/secevent+jwt',
) do |req|
req.options.context = { service_name: 'http_push_direct' }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mitchellhenke do you think this should be logged differently for workers vs inline?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, I'd make it something specific to RISC push notifications like risc_http_push_async, and the other one should probably be renamed too to match risc_http_push_direct. I kind of regret the original name being that ambiguous

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok! updated in 551ae09

Copy link
Contributor

@stevegsa stevegsa left a comment

Choose a reason for hiding this comment

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

LGTM

@zachmargolis zachmargolis merged commit 9ec4bd3 into main Aug 26, 2021
@zachmargolis zachmargolis deleted the margolis-risc-ruby-worker branch August 26, 2021 19:24
Faraday.new do |f|
f.request :instrumentation, name: 'request_log.faraday'
f.adapter :net_http
f.options.timeout = 3
Copy link
Contributor

Choose a reason for hiding this comment

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

what do you think of making these configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm open to it! Would we want all Faraday instances to share the same timeout configs, or would we want it different in different contexts?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh I missed this was merged 😛

it's probably fine for all RISC events to have the same timeout, yeah. we have some independent faraday configs for timeouts like outbound_connection_check_timeout, acuant_timeout, lexisnexis_timeout, etc. so we could follow that pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

3 participants