Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  specify next release
  simplify laziness of frames sequence
  • Loading branch information
Baptouuuu committed Jun 26, 2024
2 parents ef2a68c + 50f80be commit eb34efb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 5.1.0 - 2024-06-16

### Changed

- Requires `innmind/immutable:~5.7`
- The `Sequence` of frames to publish a message is only lazy when the message content is a lazy sequence of chunks

## 5.0.0 - 2024-03-10

### Changed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"require": {
"php": "~8.2",
"innmind/immutable": "~5.2",
"innmind/immutable": "~5.7",
"innmind/time-continuum": "~3.1",
"innmind/math": "~6.0",
"innmind/url": "~4.1",
Expand Down
47 changes: 21 additions & 26 deletions src/Transport/Protocol/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,33 +120,28 @@ public function publish(
Publish $command,
MaxFrameSize $maxFrameSize,
): Sequence {
// we use a lazy sequence to allow streaming frames for messages having
// a lazy sequence of chunks for a body
$frames = Sequence::lazyStartingWith(
Frame::method(
$channel,
Method::basicPublish,
UnsignedShortInteger::internal(0), // ticket (reserved)
ShortString::of(Str::of($command->exchange())),
ShortString::of(Str::of($command->routingKey())),
Bits::of(
$command->mandatory(),
$command->immediate(),
return $maxFrameSize
->chunk($command->message())
->map(static fn($chunk) => Frame::body($channel, $chunk))
->prepend(Sequence::of(
Frame::method(
$channel,
Method::basicPublish,
UnsignedShortInteger::internal(0), // ticket (reserved)
ShortString::of(Str::of($command->exchange())),
ShortString::of(Str::of($command->routingKey())),
Bits::of(
$command->mandatory(),
$command->immediate(),
),
),
),
Frame::header(
$channel,
MethodClass::basic,
UnsignedLongLongInteger::of($command->message()->length()),
...$this->serializeProperties($command->message()),
),
);

return $frames->append(
$maxFrameSize
->chunk($command->message())
->map(static fn($chunk) => Frame::body($channel, $chunk)),
);
Frame::header(
$channel,
MethodClass::basic,
UnsignedLongLongInteger::of($command->message()->length()),
...$this->serializeProperties($command->message()),
),
));
}

/**
Expand Down

0 comments on commit eb34efb

Please sign in to comment.