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

Initial API #2

Open
wants to merge 12 commits into
base: MOODLE_402_STABLE
Choose a base branch
from
Open

Initial API #2

wants to merge 12 commits into from

Conversation

matthewhilton
Copy link
Collaborator

@matthewhilton matthewhilton commented Nov 4, 2024

Changes

Notes

I made the decision to move the stream wrapper here and out of objectfs, since this follows the same pattern that AWS does (the AWS sdk includes a stream wrapper) - nothing about the stream wrapper is objectfs specific.

This also targets 4.2 specifically to align with ObjectFS's existing 4.2 branch, instead of having to create a new corresponding 4.4 objectfs branch.

@matthewhilton matthewhilton marked this pull request as ready for review November 5, 2024 00:25
$bodymd5 = base64_encode(hex2bin(md5($body)));
$request = new Request('PUT', $this->build_blocklist_url($key),
['Content-Type' => 'application/xml', 'content-md5' => $bodymd5], $body);
$this->client->sendAsync($request)->then(null, $this->clean_exception_sas_if_needed())->wait();

Choose a reason for hiding this comment

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

We are only using sync operations in general. Does is make sense to use the sync API instead?

Copy link
Collaborator Author

@matthewhilton matthewhilton Nov 7, 2024

Choose a reason for hiding this comment

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

We need the async api so we can use ->then to catch the exception and handle it - with the sync api I don't think this is possible without standard try/catch which is a lot messier

* Returns a request exception handling function that redacts the SAS token from error messages if needed.
* @return callable
*/
private function clean_exception_sas_if_needed(): callable {

Choose a reason for hiding this comment

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

can we just call this clean_exception_sas_token? seems a bit cleaner, I dont think the if_needed is required

Copy link
Collaborator Author

@matthewhilton matthewhilton Nov 7, 2024

Choose a reason for hiding this comment

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

i mean, it doesn't 100% of the time clean the exception sas, only if the flag/setting is enabled. So technically is is if_needed - while a bit verbose I think its good as it conveys it doesn't do it 100% of the time

* @param api $client Client to use with the stream wrapper
* @param string $protocol Protocol to register as.
*/
public static function register(api $client, $protocol = 'blob') {

Choose a reason for hiding this comment

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

Should we ever allow anything OTHER than blob here? This feels like it should be hardcoded rather than a param

Copy link
Collaborator Author

@matthewhilton matthewhilton Nov 7, 2024

Choose a reason for hiding this comment

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

Technically the protocol is a param in the stream wrapper spec.

If you changed to have it be something else it would stop working with objectfs (objectfs would need to have it changed on its side as well) but technically this plugin is not objectfs specific, so I don't see a reason why it needs to be hardcoded.

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