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

Rework the whole package #1

Draft
wants to merge 97 commits into
base: develop
Choose a base branch
from
Draft

Rework the whole package #1

wants to merge 97 commits into from

Conversation

Baptouuuu
Copy link
Member

@Baptouuuu Baptouuuu commented Dec 8, 2024

Problem

The current handling of IO in Innmind packages is split between innmind/stream and innmind/socket for the low level details on how to read/write to streams and sockets, and this package for a higher abstraction on how to handle these streams.

Other packages wanting to deal with IO has to keep track of capabilities (from innmind/stream) to open streams or directly call to classes from innmind/socket to open sockets. And also keep track of this package IO instance to wrap the streams in order to simplify their usage.

This exposes a few problems:

  • innmind/stream and innmind/socket use interfaces which limits the possibilities to add new features in minor versions
  • the interfaces are too generic to correctly understand what a user wants to do
  • there's no unified way to access streams/sockets
  • it's hard to know when it's possible to automatically close a stream (especially for files)

Solution

WIP

@Baptouuuu Baptouuuu added the enhancement New feature or request label Dec 8, 2024
@Baptouuuu Baptouuuu self-assigned this Dec 8, 2024
Copy link

codecov bot commented Dec 8, 2024

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Comment on lines +118 to +121
->flatMap(static fn($sideEffect) => match ($autoClose) {
true => $stream->close()->maybe(),
false => Maybe::just($sideEffect),
});
Copy link
Member Author

Choose a reason for hiding this comment

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

It misses the case of closing the file when the writing failed.

->write($chunk)
->maybe(),
),
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe add a call to fsync before closing the file ?

static fn() => throw new FailedToLoadStream,
);

$register(static fn() => $rewind());
Copy link
Member Author

Choose a reason for hiding this comment

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

It should close the file on partial read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant