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

Missing inward/outward mechanism on TCP / HTTP remote act #139

Open
jeromevalentin opened this issue Oct 31, 2016 · 0 comments
Open

Missing inward/outward mechanism on TCP / HTTP remote act #139

jeromevalentin opened this issue Oct 31, 2016 · 0 comments
Assignees

Comments

@jeromevalentin
Copy link

Seneca 3.2 introduced the mechanism of inward/outward on act allowing to intercept action before/after their executions. This allows to upgrade act input / output dynamically on the fly.

The same kind of mechanism is missing for remote acts.

Exemple:

    CreateInstance()
      .add('foo:1', function (args, done) {
        done(null, { BAR: args.bar })
      })
      .listen({type: 'http', port: '18997',
        inward: (context, { msg }) => {
          msg.bar += 1
          msg.inward = 'INPUT UPGRADED'
        },
        outward: (context, { msg, res, err }) => {
          res.BAR += 10
          res.inward = msg.inward
          res.outward = 'OUTPUT UPGRADED'
        }
      })
      .ready(function () {
        var siClient = CreateInstance()
          .client({type: 'http', port: '18997'})

        siClient.act('foo:1,bar:2', function (err, out) {
          if (err) return fin(err)
          Assert.equal(out.BAR, 13)
          Assert.equal(out.inward, 'INPUT UPGRADED')
          Assert.equal(out.outward, 'OUTPUT UPGRADED')
          fin()
        })
      })

Here the proposal is to use the listen options to register the inward and outward hooks.

Such mechanism would allow to:

  • log remote acts easily
  • perform some security checking (like user authentication) in inward before really performing the act with the option to reject the act
  • perform transparently some clean up on remote act results (like removing all $ properties on exposing entities for example)
jeromevalentin added a commit to jeromevalentin/seneca-transport that referenced this issue Oct 31, 2016
jeromevalentin added a commit to jeromevalentin/seneca-transport that referenced this issue Oct 31, 2016
jeromevalentin added a commit to jeromevalentin/seneca-transport that referenced this issue Oct 31, 2016
jeromevalentin added a commit to jeromevalentin/seneca-transport that referenced this issue Oct 31, 2016
@rjrodger rjrodger self-assigned this Feb 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants