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

Addressable ports in WirePattern #240

Closed
trustmaster opened this issue Jul 28, 2014 · 3 comments
Closed

Addressable ports in WirePattern #240

trustmaster opened this issue Jul 28, 2014 · 3 comments

Comments

@trustmaster
Copy link
Member

This feature has been postponed for a while due to lack of use cases, but now use cases for it are starting to emerge.

Previously, we thought of this feature as of being able to specify port indices in WirePattern parameters, e.g.

noflo.helpers.WirePattern c,
  in: ['IN[0]', 'IN[3]']
  out: 'OUT[2]'

But that didn't make much sense because specifying indices this way makes the data processing very limited.

What makes sense is dealing with addressable ports as a whole. E.g. if foo is an addressable port, WirePattern would wait for data from all sockets attached to foo to arrive before passing the data further as an array.

@bergie
Copy link
Member

bergie commented Jul 28, 2014

As a clarification, the foo example above should wait for all connected inputs only it it is an addressable param port. Input ports should cause processing on any packet, but pass the index to the processing function

@trustmaster
Copy link
Member Author

In some cases you'd want input ports to wait for all sockets too. We might want a config option for this.

@trustmaster
Copy link
Member Author

See implementation details below:

If a param port is addressable, the component waits for data on all its attached indexes to arrive before proceeding. In proc function such a parameter is accessible as an object with keys matching port indexes, e.g.:

component.params.arr = {
  0: 'foo',
  1: 'bar',
  2: 'baz'
}

If an in port is addressable, the component activates the proc function whenever data arrives, given that data on other ports has also been received. The data on an addressable port is an object with keys matching port indexes. E.g. if just one packet was received while data on other ports arrived, it will contain just one element, e.g.:

data.arr = {
  1: 'bar'
}

But if several indexes were triggered while waiting for other ports, it may contain several elements:

data.arr = {
  0: 'foo',
  1: 'bar'
}

Therefore for components with just one in port, it is always passed one array object per invocation.

There are cases when a component should act the opposite way: wait for just any param index or wait for in on all indexes at once. That's why there are several "waiting" policies for array ports available, with the above example used by default:

noflo.helpers.WirePattern component,
  in: [ 'd1', 'd2' ]
  params: 'p'
  out: 'out'
  arrayPolicy: # these are defaults
    in: 'any' # trigger on any index
    params: 'all' # wait for all indexes

Other combinations are also possible, e.g.:

noflo.helpers.WirePattern component,
  in: [ 'd1', 'd2' ]
  params: 'p'
  out: 'out'
  arrayPolicy:
    in: 'all' # wait for all indexes
    params: 'all' # wait for all indexes

@bergie bergie closed this as completed in 1416622 Aug 4, 2014
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

No branches or pull requests

2 participants