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: make StateHandle's Id public #1048

Closed
wants to merge 3 commits into from

Conversation

discord9
Copy link
Contributor

make StateHandle's Id public, so one can link state with subgraph by using something like BTreeMap<SubgraphId, BTreeSet<StateId>>

@MingweiSamuel
Copy link
Member

Whats your use case? Also would prefer to have it as a method instead

@discord9
Copy link
Contributor Author

discord9 commented Jan 30, 2024

Whats your use case? Also would prefer to have it as a method instead

Then I should make it a method then, how about state_id() for naming?
For example, I want to allow related subgraph to run when the state related to it fulfilled certain condition(i.e. certain amount of time have passed), I'm using scheduled api heavily in my usecase, but I feel hydro lang could alos be benefited from having a way to manage state with id?

// Suppose this state have some timed task 
// that needed to be done later when certain condition is fulfilled
// call `Hydroflow::add_state::<Rc<RefCell<State>>>` and also register state in manager with it's id
let state = manager.add_state::<State>();
let state_id = state.state_id();
let subgraph_id = df.add_subgraph(/* code that use this state*/);
// This manager register state to subgraph by id, and schedule related subgraph to run when state's condition is fulfilled
manager.register_state_to_subgraph*(state_id, subgraph_id);

MingweiSamuel pushed a commit to MingweiSamuel/hydroflow that referenced this pull request Feb 1, 2024
@MingweiSamuel
Copy link
Member

Would #1054 work for you?

MingweiSamuel pushed a commit to MingweiSamuel/hydroflow that referenced this pull request Feb 2, 2024
@discord9
Copy link
Contributor Author

discord9 commented Feb 2, 2024

Would #1054 work for you?

Yes, it can cover my use case, thanks

@discord9 discord9 closed this Feb 2, 2024
MingweiSamuel added a commit that referenced this pull request Feb 2, 2024
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.

2 participants