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

Debugger: File breakpoint storage #887

Merged
merged 12 commits into from
Feb 8, 2018
Merged

Debugger: File breakpoint storage #887

merged 12 commits into from
Feb 8, 2018

Conversation

chingor13
Copy link
Contributor

Adds a file-based implementation of BreakpointStorageInterface. This will allow windows users to use debugger.

Note: we're using flock for attempting to make our file read/writes safe between 2 separate processes.

@chingor13 chingor13 requested a review from tmatsuo as a code owner February 7, 2018 18:29
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 7, 2018
@dwsupplee
Copy link
Contributor

This may be helpful: https://github.com/GoogleCloudPlatform/google-cloud-php/tree/master/src/Core/Lock

We could update the interface to pass in a flag to use either a blocking or non blocking lock

@chingor13
Copy link
Contributor Author

Awesome, I'll take a look at those.

@chingor13
Copy link
Contributor Author

chingor13 commented Feb 7, 2018

Looks like I also need to add an option for the lock type. In this use case, it's fine to have many readers so we don't need to acquire an exclusive lock when reading.

The new signature would either need to be:

  • public function acquire($blocking = true, $exclusive = true) or
  • public function acquire(array $options = []) with blocking and exclusive option keys.

edited: blocking defaults to true (unlike symfony) because that's the current behavior for FlockLock

Add options to LockInterface#acquire for blocking and exclusive locking
options.
@chingor13
Copy link
Contributor Author

@dwsupplee Went with public function acquire(array $options = []). For implementations that do not support shared locks, we trigger an E_USER_WARNING and ignore that option.

@chingor13 chingor13 requested a review from dwsupplee February 7, 2018 20:05
@dwsupplee
Copy link
Contributor

A cursory look at the second signature SGTM. I am away from my desk for a bit, will review this and #848 tonight :).

@@ -25,10 +25,18 @@
/**
* Acquires a lock that will block until released.

This comment was marked as spam.

*
* @type bool $blocking Whether the process should block while waiting
* to acquire the lock. **Defaults to** true.
* @type bool $exclusive If true, acquire an excluse (write) lock. If

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

// Acquire an exclusive write lock (blocking). There should only be a
// single Daemon that can call this.
try {
$this->lock->acquire();

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,48 @@
<?php
/**
* Copyright 2017 Google Inc.

This comment was marked as spam.

Copy link
Contributor

@dwsupplee dwsupplee left a comment

Choose a reason for hiding this comment

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

Looks really nice! One last little thing I noticed.

*
* @type bool $blocking Whether the process should block while waiting
* to acquire the lock. **Defaults to** true.
* @type bool $exclusive If true, acquire an excluse (write) lock. If

This comment was marked as spam.

@dwsupplee dwsupplee merged commit 0876c0f into googleapis:master Feb 8, 2018
@chingor13 chingor13 deleted the file-breakpoint-storage branch February 8, 2018 19:42
@chingor13 chingor13 mentioned this pull request Feb 8, 2018
@jdpedrie jdpedrie mentioned this pull request Feb 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants