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

AdminServer is now the only one to send_webhook #58

Merged
merged 6 commits into from
Apr 5, 2021

Conversation

farskipper
Copy link

First stab at the refactor. All the tests are passing and seems to be working fine with the toolbox.

Any event with a topic acapy::webhook::(.*) will get forwarded as a webhook. However, I'm thinking now might be a good time to improve the naming convention of these events, while still maintaining backwards compatibility with webhook topics.

i.e. a mapping from event name to webhook topic might be:

{
  "acapy::basicmessage_received": "basicmessages",
  "acapy::ping": "ping",
  "acapy::ping_response": "ping",
  "acapy::driver_get_active_menu": "get-active-menu",
  "acapy::driver_perform_menu_action": "perform-menu-action",
  "acapy::problem_report": "problem_report",
}

@farskipper farskipper requested a review from dbluhm March 24, 2021 22:58
Signed-off-by: Matthew Wright <matthew@smallhelm.com>
@dbluhm
Copy link
Member

dbluhm commented Mar 25, 2021

However, I'm thinking now might be a good time to improve the naming convention of these events, while still maintaining backwards compatibility with webhook topics.

i.e. a mapping from event name to webhook topic might be:

{
  "acapy::basicmessage_received": "basicmessages",
  "acapy::ping": "ping",
  "acapy::ping_response": "ping",
  "acapy::driver_get_active_menu": "get-active-menu",
  "acapy::driver_perform_menu_action": "perform-menu-action",
  "acapy::problem_report": "problem_report",
}

I agree with this approach with the one suggestion that adding more "namespaces" could be nice. So acapy::basicmessage_received might be acapy::basicmessage::received.

aries_cloudagent/admin/base_server.py Show resolved Hide resolved
aries_cloudagent/core/conductor.py Show resolved Hide resolved
aries_cloudagent/core/dispatcher.py Outdated Show resolved Hide resolved
aries_cloudagent/core/event_bus.py Outdated Show resolved Hide resolved
aries_cloudagent/core/profile.py Show resolved Hide resolved
aries_cloudagent/messaging/responder.py Outdated Show resolved Hide resolved
@dbluhm
Copy link
Member

dbluhm commented Mar 25, 2021

Looking pretty good so far. Left some comments and thoughts.

Signed-off-by: Matthew Wright <matthew@smallhelm.com>
Signed-off-by: Matthew Wright <matthew@smallhelm.com>
@farskipper
Copy link
Author

farskipper commented Mar 25, 2021

Made some changes:

  • Brought back responder.send_webhook with a deprecation warning
  • Added comment to explain why if TYPE_CHECKING is used
  • Added EVENT_WEBHOOK_MAPPING

Question: Is it ok to remove these?

  • BaseAdminServer.add_webhook_target - superseded by profile.settings.get("admin.webhook_urls")
  • BaseAdminServer.remove_webhook_target - superseded by profile.settings.get("admin.webhook_urls")
  • BaseAdminServer.send_webhook - Now that we have events, this seems like an implementation detail, not necessarily something all admin servers need to support.

@dbluhm
Copy link
Member

dbluhm commented Mar 30, 2021

BaseAdminServer.send_webhook - Now that we have events, this seems like an implementation detail, not necessarily something all admin servers need to support.

Sounds good to me

  • BaseAdminServer.add_webhook_target - superseded by profile.settings.get("admin.webhook_urls")
  • BaseAdminServer.remove_webhook_target - superseded by profile.settings.get("admin.webhook_urls")

I see, I didn't pick up on the self.webhook_urls not even being used in the send_webhook method; I defer to your findings.

@dbluhm
Copy link
Member

dbluhm commented Mar 30, 2021

Apologies, I've lost track of all the different conversations -- are there further changes needed after our discussion or is this ready for final review?

@farskipper
Copy link
Author

farskipper commented Mar 30, 2021

@dbluhm I think it's ready for final review if we are ok removing BaseAdminServer.[add/remove]_webhook_target All the tests are passing and seems to work fine with the toolbox.

Are there other implementations of BaseAdminServer running around out there? If so we'll just have to note that it's a breaking change to rely on add_webhook_target and you should be using profile.settings.get("admin.webhook_urls") instead. Which I think is fine b/c that's all it's really using right now anyways.

Copy link
Member

@dbluhm dbluhm left a comment

Choose a reason for hiding this comment

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

Nice work! Looking really good!

Looking through, I think we should generalize the send_webhook method on BaseRecord. At the moment, record updates (which as it turns out is one of the most useful and frequent types of webhook event sent out) are emitting an event specifically scoped to the webhook.

I recommend:

  1. Rename BaseRecord.send_webhook to something event oriented, perhaps emit_event or similar.
  2. Use acapy::RECORD_TOPIC::STATE as the topic.
    • This will require adding mappings as we have for the basic messages and pings.

This one might get a little messy but I think I would also recommend modifying the BaseRecord.save and BaseRecord.post_save (and any other relevant) methods to take a bool event instead of webhook or else keep webhook around for backwards compatibility and add the event but make sure they are the same and emit a deprecation warning on webhook usage. I'm not bent on this one but I think abstracting away the webhook as much as possible will make the system cleaner overall. If this ends up being a huge and/or brittle change, we'll likely need to regroup and come up with a different solution.

Signed-off-by: Matthew Wright <matthew@smallhelm.com>
@farskipper
Copy link
Author

@dbluhm Ok, I made a PR to make those changes: #59 I did a PR so it'd be easy to diff and back out if we decide against it.

farskipper and others added 2 commits April 5, 2021 13:06
Signed-off-by: Matthew Wright <matthew@smallhelm.com>
…ase_record

Base record replace webhooks with events
@dbluhm dbluhm merged commit fd29562 into feature/event-bus Apr 5, 2021
@farskipper farskipper deleted the event-bus-webhook-refactor branch April 5, 2021 19:42
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