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: cdp.Client impl Contextable interface #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Fly-Playgroud
Copy link
Collaborator

Implement the Contextable interface for cdp.Client, preparing to introduce *goob.Observable:

  • Add a ctx field in the Client struct to store the context of the current instance.
  • Add a GetContext method to retrieve the context of the current instance.
  • Add a Context method to create a copy of the client with a specified context.
  • Update the New method to set a default context for newly created client instances.
  • Modify the test files and utils.go to support the new context management functionality.

Implement the Contextable interface for cdp.Client, preparing to introduce *goob.Observable:
- Add a ctx field in the Client struct to store the context of the current instance.
- Add a GetContext method to retrieve the context of the current instance.
- Add a Context method to create a copy of the client with a specified context.
- Update the New method to set a default context for newly created client instances.
- Modify the test files and utils.go to support the new context management functionality.
- Due to clone use pointer
- Change pending from sync.Map to *sync.Map- This modification ensures proper memory management and prevents potential memory leaks
@@ -48,7 +48,9 @@ type Client struct {

ws WebSocketable

pending sync.Map // pending requests
ctx context.Context
Copy link
Member

Choose a reason for hiding this comment

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

Will it impact the performance? Better to create a simple benchmark for it.

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