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

feat(spells): support empty trigger configs [NET-316] #1412

Merged
merged 8 commits into from
Jan 18, 2023
Merged

Conversation

kmd-fl
Copy link
Contributor

@kmd-fl kmd-fl commented Jan 17, 2023

An empty trigger config allows:

  1. not to subscribe a spell to any triggers on installation
  2. unsubscribe a spell from its triggers

Also, remove the update interface from the spell-event-bus crate since all it needs to do is expressed via subscribe/unsubscribe methods.

An empty trigger config is used either to unsubscribe a spell from triggers
or to not subscribe at all if it was used on installation.

Also remove updating interface inside the spell-event-bus, since
it's not needed.
@kmd-fl kmd-fl changed the title Support empty trigger configs feat(spells): support empty trigger configs Jan 17, 2023
#[test]
fn spell_update_config() {
let swarms = make_swarms(1);
//log_utils::enable_logs();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
//log_utils::enable_logs();

)"#,
client.peer_id
);
// create periodic spell
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
// create periodic spell

#[test]
fn spell_update_config_stopped_spell() {
let swarms = make_swarms(1);
//log_utils::enable_logs();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
//log_utils::enable_logs();

.wrap_err("connect client")
.unwrap();

// Create spell that do nothing.
Copy link
Member

@folex folex Jan 17, 2023

Choose a reason for hiding this comment

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

Suggested change
// Create spell that do nothing.
// Create a spell that does nothing.

}
was_removed
Copy link
Member

Choose a reason for hiding this comment

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

nice!

Comment on lines -139 to -147
let new_len = self.scheduled.len();
let removed = self.subscribers.remove(spell_id);
prev_len != new_len || removed
}

fn update(&mut self, spell_id: &SpellId, config: &SpellTriggerConfigs) {
if self.unsubscribe(spell_id) {
self.subscribe(spell_id.clone(), config);
}
Copy link
Member

Choose a reason for hiding this comment

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

awesome ^__^

)));
}
} else {
log::trace!("empty config given for spell {}", spell_id);
Copy link
Member

Choose a reason for hiding this comment

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

can you include particle_id in this log please? I think one day we might want to see this message when debugging spell installation

sorcerer/src/spells.rs Outdated Show resolved Hide resolved
kmd-fl and others added 2 commits January 18, 2023 14:16
Co-authored-by: Aleksey Proshutisnkiy <justprosh@users.noreply.github.com>
@kmd-fl kmd-fl changed the title feat(spells): support empty trigger configs feat(spells): support empty trigger configs [NET-316] Jan 18, 2023
@linear
Copy link

linear bot commented Jan 18, 2023

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.

None yet

3 participants