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

Add OnStart callback for emulator start #566

Closed
wants to merge 2 commits into from

Conversation

chasefleming
Copy link
Member

@chasefleming chasefleming commented Feb 9, 2024

Closes #565


For contributor use:

  • Targeted PR against master branch
  • Linked to GitHub issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the GitHub PR explorer
  • Added appropriate labels

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7496500) 52.62% compared to head (f2abb88) 53.30%.
Report is 85 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #566      +/-   ##
==========================================
+ Coverage   52.62%   53.30%   +0.68%     
==========================================
  Files          29       29              
  Lines        3795     3876      +81     
==========================================
+ Hits         1997     2066      +69     
- Misses       1646     1652       +6     
- Partials      152      158       +6     
Flag Coverage Δ
unittests 53.30% <ø> (+0.68%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chasefleming chasefleming changed the base branch from master to release/v0 February 9, 2024 23:03
@turbolent
Copy link
Member

Nice! What is the release/v0 branch?

@chasefleming
Copy link
Member Author

chasefleming commented Feb 11, 2024

@turbolent we need a way to still release non v1 features now that everything has been merged to master. I cut this branch off of the v0.59.0 commit, so have the ability to do more releases like v0.60.0 if we need a change in the meantime. This means we'll have to cherry pick everything we do over here into a PR for the master branch as well. Don't foresee many changes though.

@turbolent
Copy link
Member

Sounds good! 👍 There's a discussion about having such a branch in #564, maybe good to coordinate and document it, so we don't end up with multiple different ones

@chasefleming
Copy link
Member Author

Thanks for the heads up @turbolent . Left a comment on there.

@chasefleming chasefleming added the Feature A new user feature or a new package API label Feb 11, 2024
@bluesign
Copy link
Collaborator

bluesign commented Feb 12, 2024

@chasefleming is this works? afaik start call is blocking (library we used there, graceland is blocking actually)

I think emulator should start after the start call anyway, what was the issue there? Is there something creating delay ?

@turbolent turbolent mentioned this pull request Feb 12, 2024
6 tasks
@chasefleming
Copy link
Member Author

@bluesign you're right. I need to rethink my approach. Moving this to a draft PR. Sorry, what do you mean by "start after start call." If start blocks, what I am trying to do is figure out a way to notify whatever called it that you can continue on a next step. e.g. deploy a contract to the emulator.

@bluesign
Copy link
Collaborator

bluesign commented Feb 12, 2024

@chasefleming who is the caller here? who is starting emulator I mean. I think if you call Listen before Start, emulator should be ready anyway, OS will make socket wait till it is handled.

@chasefleming chasefleming marked this pull request as draft February 12, 2024 20:09
@chasefleming
Copy link
Member Author

chasefleming commented Feb 12, 2024

@bluesign In one use case, the CLI is the caller. I tried this, but unless I put a sleep to delay it the following code fails because it's not actually ready:

err := emulatorServer.Listen()
if err != nil {
	// TODO: handle error
}

go func() {
	emulatorServer.Start()
}()
fmt.Println("Emulator server is ready")

Any ideas or see anything I'm doing wrong?

@chasefleming
Copy link
Member Author

This is addressed by this: onflow/flow-go-sdk#578

@chasefleming chasefleming deleted the chasefleming/onstart-callback branch March 14, 2024 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A new user feature or a new package API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow a callback to be trigger after emulator has started
4 participants