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

[RFC] Higher-level AdapterManager #54

Open
Yoric opened this issue Mar 30, 2016 · 1 comment
Open

[RFC] Higher-level AdapterManager #54

Yoric opened this issue Mar 30, 2016 · 1 comment

Comments

@Yoric
Copy link
Collaborator

Yoric commented Mar 30, 2016

Spinoff from an idea by @mcav in #53.

We could rewrite the AdapterManager's channel API as follows:

/// A channel, which may have read/write capabilities.
pub struct Channel {
  id: Id<Channel>,
  kind: ChannelKind,
  service: Id<ServiceId>,
  pub properties: PropertyBag,
  pub fetch: Option<Box< Fn(FetchArgs) -> Result<Value, Error> + Sync + Send>>,
  pub send: Option<Box< Fn(SendArgs) -> Result<(), Error> + Sync + Send>>,
  pub watch: Option<Box< Fn(WatchArgs) -> Result<WatchGuard, Error> + Sync + Send>>,
  // Possibly more in the future.
}
impl Channel {
  /// Create an empty channel.
  pub fn new(id: &Id<Channel>, service: &Id<ServiceId>, kind: ChannelKind) -> Self;
}

impl AdapterManger {
  pub fn add_channel(channel: Channel) -> Result<(), Error>
}

Pros

  • This relieves Adapters from having to maintain their own mapping between Id<Getter>/Id<Setter>, actual devices, actual implementation.
  • Extending this with future capabilities (e.g. delete) should be quite simple.
  • We can expose a data structure Channel much like this to the REST API, and it should often be easier to use than our current separate getters/setters.

Cons

  • The current AdapterManager manages to combine various fetch (respectively send, watch) requests by Adapter and send them together to minimize communications. I don't see how to do this with this design.
@Yoric
Copy link
Collaborator Author

Yoric commented Mar 30, 2016

Cc @fabricedesre , @cr , @julienw , @dhylands , @azasypkin , @aosmond .

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

1 participant