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

Filter implementation #45

Open
sjrct opened this issue Sep 30, 2016 · 2 comments
Open

Filter implementation #45

sjrct opened this issue Sep 30, 2016 · 2 comments

Comments

@sjrct
Copy link
Member

sjrct commented Sep 30, 2016

The simplest potential filter implementation should be done for 1.0. Baha, this one is for you! (*^3^)/~☆

You probably should wait for the package PR (#44) to be rolled in, as you will not have to worry about backwards compatibility/upgrading to the new format.

There are three things that need to be done for filters.

  1. Implement the HalFilter class. This should be in a somewhat similar vain to the HalObject/HalModule/HalAgent classes, but it should not inherit from HalObject, as it does not act as a message sender/receiver, just an intermediary. The init called by __init__ paradigm used in HalObject should be implemented. There should also, and most critically, be an abstract method called filter or something similar that takes in a message, and returns either a processed (or unprocessed) message or None, with None indicating that the message should not be propagated any further.
  2. There needs to be something that associates filters with an module or agent. I was thinking a list of filter class names in the module/agent instance config block that would be assigned to a filters key on the HalObject. This should probably be done in the __init__ method in halobject.py.
  3. Lastly, there needs to be something that filters messages. In halobject.py, the _queue_msg function is called to queue each incoming message to an agent or module. The filtering could be done here (it could also be done on receive, to put it on the receiver's event queue, but it doesn't really make too much of a difference I think). So before queuing the message, the message should be passed to each of the registered filter's filter method, which returns a perhaps different ("preprocessed", perhaps) message or None. If None is returned, the message should be dropped, not passed to any more filters and not queued.
@sjrct sjrct added this to the Version 1.0.0 milestone Sep 30, 2016
@richteer
Copy link
Contributor

richteer commented Oct 3, 2017

but it should not inherit from HalObject, as it does not act as a message sender/receiver, just an intermediary.

Is this still relevant? I believe this issue was created before RIs and the rise of message passing. I think the easiest way to implement this without adding too much special case stuff would be to have it subclass HalModule, and instantiate it as a module.

This way, the HalFilter objects simply act as an intermediary module that continues passing (or rejects...) messages without altering the origin. That is, a message sent to a filter by a module continues to have that module as its origin.

@sjrct sjrct removed this from the Version 1.0.0 milestone Nov 8, 2017
@richteer
Copy link
Contributor

richteer commented Mar 5, 2019

See #132

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

3 participants