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

Decentralizing: Removing big centralized Value #520

Merged
merged 12 commits into from
Jun 10, 2016
Merged

Conversation

Yoric
Copy link

@Yoric Yoric commented Jun 8, 2016

This PR removes the big centralized enum Value, effectively ending all centralization in Taxonomy. The first two beneficiaries are Thinkerbell (which now defines its own value type RuleSource) and WebPush (which now defines its own value type WebPushNotify).

I still have a few PRs planned after this lands, but at this stage, Taxonomy will be Decentralized \o/

@aosmond
Copy link
Contributor

aosmond commented Jun 8, 2016

r=me for WebPush.

@mcav
Copy link
Contributor

mcav commented Jun 8, 2016

thinkerbell lgtm

@@ -4,6 +4,8 @@
#![plugin(clippy)]
// To prevent clippy being noisy with derive(...)
#![allow(used_underscore_binding)]
#![allow(let_unit_value)] // For some reason, clippy decides to display this warning, without
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: finish that sentence and remove extra blank line.

@fabricedesre
Copy link
Collaborator

r=me thanks!

udn = String::from(&udn[5..]);
}
.trim_left_matches("uuid:")
.to_owned();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Thanks for the rewrite. I'd probably put the comment in front of the let. I think the comment in the middle of a statement looks funny.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I rewrote that only because Clippy kept pestering me about the style of this statement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I filed a bug with clippy, and it's been fixed in the latest version (not sure when it will be released).
See: https://github.com/Manishearth/rust-clippy/issues/975

Looks like it should be fixed in release 0.0.72

@dhylands
Copy link
Contributor

dhylands commented Jun 9, 2016

r=me for camera stuff.

@Yoric
Copy link
Author

Yoric commented Jun 9, 2016

Adding:

  • r? @fabricedesre for TTS (which I had forgotten in the previous PR);
  • Cc @azasypkin because of upcoming breakages.

@Yoric
Copy link
Author

Yoric commented Jun 9, 2016

Adding r? @npark-mozilla for integration tests.

Also, @azasypkin , you can now look at the integration tests to see the API changes.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 32.594% when pulling 4ced0a6 on Yoric:refactor-7 into 711ea22 on fxbox:master.

@cr
Copy link
Contributor

cr commented Jun 9, 2016

r+ for the Hue changes and the changes to the Color type.

fn should_send(&self, value: &Value, _: EventType) -> bool {
self.contains(value)
self == value // FIXME: This won't scale up to interesting ranges.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the path forward with this FIXME? Maybe you could file an issue and put the issue # here and above ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this FIXME is actually a reminder that should_send only works for simple cases. For more complicated cases, well, a different algorithm will be needed. As I have no clue about which cases we are going to handle in the future, I don't really see how I can be much more specific.

@azasypkin
Copy link
Member

f+ from the client side (app related PR is fxbox/app#172)!

Just a few notes (maybe they are the same on master though, didn't check):

  1. When incorrect rule is saved (e.g. without execute part), there is very vague error is returned {"thinkerbell-add-rule":{"Error":"Internal Error"}};

  2. It was there before, but since you're updating related pieces: it's a bit hard to distinguish successful response with value and failed one (especially for batch requests where response code should be 200 in any case):

  • {"OpenZWave-d32394d4-01000000024c0000":"Closed"};
  • {"OpenZWave-d32394d4-01000000024c0000":{"Error":{"OperationNotSupported": ...}}

Currently we rely on Error property of returned object, but that's dumb :) Theoretically valid value can be object with Error property. Something like this {"OpenZWave-d32394d4-01000000024c0000":{ value: "Closed", error: {"OperationNotSupported": ...}} would probably be less confusing.

@@ -168,7 +178,15 @@ impl ParseError {
}

#[derive(Debug)]
pub struct JSONError(error::Error);
pub struct JSONError(pub error::Error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wondering why you need the "pub" for the argument ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er... I don't remember, but I remember that I do :)

@Yoric
Copy link
Author

Yoric commented Jun 9, 2016

  1. When incorrect rule is saved (e.g. without execute part), there is very vague error is returned {"thinkerbell-add-rule":{"Error":"Internal Error"}};

Almost sure that's not new. Looks like something that should be solved as part of #519.

  1. It was there before, but since you're updating related pieces: it's a bit hard to distinguish successful response with value and failed one (especially for batch requests where response code should be 200 in any case):
    [...]
    Currently we rely on Error property of returned object, but that's dumb :) Theoretically valid value can be object with Error property. Something like this {"OpenZWave-d32394d4-01000000024c0000":{ value: "Closed", error: {"OperationNotSupported": ...}} would probably be less confusing.

Good idea, shouldn't be too hard. Can you file an issue?

}
}
}
mopafy!(Data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so that I understand properly, this is how we'll let adapters implement their own data types ?
Mopa is like an "open" enum ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, yes. Mopa is a more flexible + type-safe Any that can be used much more comfortably to implement an open enum.

/// A human-readable description of the _type_ of the value.
///
/// Used mainly in `TypeError` error messages.
fn description() -> String where Self: Sized;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if this could be a &'static str like for Errors ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I don't really care so just forget this comment :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes things a bit more complicated for Range<T>, unfortunately.

@julienw
Copy link
Contributor

julienw commented Jun 9, 2016

r=me, I left some nits and questions but not really important.

We noticed that a DoorLock now uses Open/Closed instead of Locked/Unlocked, and I found that's because DOOR_IS_LOCKED uses Open/Closed. Is it expected ?

@azasypkin
Copy link
Member

Good idea, shouldn't be too hard. Can you file an issue?

Done #522!

@nojunpark
Copy link

r+ for me. glad to see the syntax got simpler. It would be awesome if the wiki (https://wiki.mozilla.org/Connected_Devices/Projects/Project_Link/Taxonomy) is updated as well :)

@Yoric
Copy link
Author

Yoric commented Jun 9, 2016

We noticed that a DoorLock now uses Open/Closed instead of Locked/Unlocked, and I found that's because DOOR_IS_LOCKED uses Open/Closed. Is it expected ?

I'll fix this.

@fabricedesre
Copy link
Collaborator

r=me for tts

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 32.614% when pulling cc7dd5c on Yoric:refactor-7 into 711ea22 on fxbox:master.

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.

10 participants