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

ubus: add explicit support for deferring incoming requests #195

Merged
merged 1 commit into from
Apr 7, 2024

Conversation

nbd168
Copy link
Contributor

@nbd168 nbd168 commented Apr 7, 2024

This is needed when asynchronously processing requests via uloop, e.g. using uclient.

@jow-
Copy link
Owner

jow- commented Apr 7, 2024

Can you try to add a short ucode usage example to the commit message itself?

So to understand the intent correctly: you want to be able to return from the callback without the request context being replied to, instead you want to stow away the context somewhere and invoke its .reply() later from another scope, e.g. within some timer or io callback?

This is needed when asynchronously processing requests via uloop, e.g.
using uclient.

Example script:

  let libubus = require("ubus");
  let uloop = require("uloop");

  uloop.init();
  let ubus = libubus.connect();
  ubus.publish("test", {
      test: {
          call: function(req) {
              req.defer();
              uloop.timer(1000, () => {
                  req.reply({ msg: "Hello, world!" }, 0);
              });
          },
          args: {}
      },
  });
  uloop.run();
  uloop.done();

Signed-off-by: Felix Fietkau <[email protected]>
@nbd168
Copy link
Contributor Author

nbd168 commented Apr 7, 2024

Correct. I added the example that I was testing with.

@nbd168
Copy link
Contributor Author

nbd168 commented Apr 7, 2024

I'm planning on using this in combination with the uclient module that I wrote in order to build a hostapd 'afcd' replacement for 6 GHz frequency coordination (required by FCC for 6 GHz standard power levels).

@jow- jow- merged commit 5507654 into jow-:master Apr 7, 2024
6 checks passed
@jow-
Copy link
Owner

jow- commented Apr 7, 2024

Merged, thanks!

@nbd168 nbd168 deleted the ubus-defer branch May 2, 2024 08:54
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