-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add series of meta effectors for composite operations #605
base: master
Are you sure you want to change the base?
Conversation
@Override | ||
public void apply(EntityLocal entity) { | ||
Maybe<Effector<?>> effectorMaybe = entity.getEntityType().getEffectorByName(effector.getName()); | ||
if (!effectorMaybe.isAbsentOrNull()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the logic in this has been commented out! If none is required, makes overriding the entire method superfluous.
throw new IllegalArgumentException("Effector parameter cannot be parsed: " + effectorDetails); | ||
} | ||
effectorName = Iterables.getOnlyElement(keys); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about instanceof List
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the individual effector elements of the list of effectors, they can only be a String
or a Map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean what if someone passes a list - effectorName = Strings.toString(effectorDetails);
does not feel like the right way to handle that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why would they do that? They would be creating a list of lists, as in the third option below, and if someone does that, then I'm happy for things to just break...
compose:
- name1 # string
- name2: # map
key: value
- [ whyWouldYouDoThis ] # list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, it would clearly be a mistake - prefer to fail fast, so perhaps throwing an exception rather than allowing it to pass by calling toString()
@grkvlt there should be some unit tests at least along with these, can you add some? |
|
||
public Body(Effector<?> eff, ConfigBag params) { | ||
super(eff, params); | ||
Preconditions.checkNotNull(params.getAllConfigRaw().get(COMPOSE.getName()), "Effector names must be supplied when defining this effector"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Preconditions.checkNotNull(params.get(COMPOSE), "compose must be supplied when defining a compose effector: %s", params)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll fix all of these to have better error messages.
|
||
public Body(Effector<?> eff, ConfigBag params) { | ||
super(eff, params); | ||
Preconditions.checkNotNull(params.getAllConfigRaw().get(LOOP.getName()), "Effector names must be supplied when defining this effector"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Preconditions.checkNotNull(params.get(LOOP), "loop must be supplied when defining a loop effector: %s", params)
?
|
||
public Body(Effector<?> eff, ConfigBag params) { | ||
super(eff, params); | ||
Preconditions.checkNotNull(params.getAllConfigRaw().get(SEQUENCE.getName()), "Effector names must be supplied when defining this effector"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Preconditions.checkNotNull(params.get(SEQUENCE), "sequence must be supplied when defining a sequence effector: %s", params)
?
|
||
public Body(Effector<?> eff, ConfigBag params) { | ||
super(eff, params); | ||
Preconditions.checkNotNull(params.getAllConfigRaw().get(FUNCTION.getName()), "Function must be supplied when defining this effector"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Preconditions.checkNotNull(params.get(FUNCTION), "function must be supplied when defining a function effector: %s", params)
?
Also what about INPUT
?
b60b332
to
e3a936f
Compare
|
||
protected long delay; | ||
|
||
private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to inherit the ScheduledExecutorService
of the parent class and use that?
ca62777
to
de72251
Compare
caac7c4
to
9413b4b
Compare
@grkvlt this PR is rather large, and missing tests. I suggest it is closed for now and we work out a way to break this down. Some ideas for how to break it down: This should make it easier to review and merge. What are your thoughts on this? |
@Graeme-Miller I think once the tests are added it should be OK, as the individual effectors are all reliant on a single parent abstract class, so they fit together. I will work with @robertgmoss on getting this done and reviewed. |
d6a09d1
to
8f88cfb
Compare
6ac8152
to
17f7e0f
Compare
17f7e0f
to
7f28d19
Compare
@grkvlt Unfortunately it looks like this branch has gone stale since you updated it. Can you have a look to see if it is still relevant (I suspect it is), and rebase against master Thanks |
Adds
ComposeEffector
,SequenceEffector
,TransformEffector
andLoopEffector
for orchestrating effector calls in blueprints.Also
ScheduledEffectorPolicy
andPeriodicEffectorPolicy
policies to execute an effector at a scheduled time or periodically.TODO Add tests for each new effector type and basic documentation