iilyak commented on PR #5576:
URL: https://github.com/apache/couchdb/pull/5576#issuecomment-2997368872
> Maybe instead of a separate command/call altogether, add an option to the
write_header call to sync or not, defaulting to not not sync. Sometimes boolean
flags are not as descriptive, so we can make it into an options list `[sync]`?
Handling flag doesn't land naturally into maybe pattern. The `maybe` version
(without flag) would look like:
```erlang
handle_call({commit_header, Bin}, _From, #file{fd = Fd} = File) ->
maybe
ok ?= fsync(Fd),
{ok, NewFile} ?= do_write_header(Bin, File),
ok ?= fsync(Fd),
{reply, ok, NewFile}
else
{{error, _} = Error, State} ->
{reply, Error, State};
{error, _} = Error ->
% We're intentionally dropping all knowledge
% of this Fd so that we don't accidentally
% recover in some whacky edge case that I
% can't fathom.
{stop, Error, Error, #file{fd = nil}}
end.
```
The `maybe` matches do not support guards and also the `?=` is only at the
top level of `maybe/end`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]