-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Add/Remove super stream feature (#357)
* Implement Add/Remove super stream feature * add PartitionsSuperStreamSpec to configure the Partitions * add BindingsSuperStreamSpec to configure the Bindings --------- Signed-off-by: Gabriele Santomaggio <[email protected]>
- Loading branch information
1 parent
335a0f3
commit ac23f56
Showing
22 changed files
with
585 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"erlang": "26.1.2", | ||
"rabbitmq": "3.13.0-rc.2" | ||
"rabbitmq": "3.13.0-rc.4" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// This source code is dual-licensed under the Apache License, version | ||
// 2.0, and the Mozilla Public License, version 2.0. | ||
// Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. | ||
|
||
using System; | ||
using System.Buffers; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace RabbitMQ.Stream.Client; | ||
|
||
internal readonly struct CreateSuperStreamRequest : ICommand | ||
{ | ||
private const ushort Key = 29; | ||
private readonly string _superStream; | ||
private readonly uint _corrId; | ||
private readonly IDictionary<string, string> _arguments; | ||
private readonly List<string> _partitions; | ||
private readonly List<string> _bindingKeys; | ||
|
||
internal CreateSuperStreamRequest(uint corrId, string superStream, | ||
List<string> partitions, List<string> bindingKeys, IDictionary<string, string> args) | ||
{ | ||
_corrId = corrId; | ||
_superStream = superStream; | ||
_partitions = partitions; | ||
_bindingKeys = bindingKeys; | ||
_arguments = args; | ||
} | ||
|
||
public int SizeNeeded | ||
{ | ||
get | ||
{ | ||
var size = | ||
2 | ||
+ 2 | ||
+ 4 | ||
+ WireFormatting.StringSize(_superStream); | ||
|
||
size += 4 + _partitions.Sum(WireFormatting.StringSize); | ||
size += 4 + _bindingKeys.Sum(WireFormatting.StringSize); | ||
size += 4 | ||
+ _arguments.Sum(x => WireFormatting.StringSize(x.Key) + WireFormatting.StringSize(x.Value)); | ||
return size; | ||
} | ||
} | ||
|
||
public int Write(Span<byte> span) | ||
{ | ||
var command = (ICommand)this; | ||
var offset = WireFormatting.WriteUInt16(span, Key); | ||
offset += WireFormatting.WriteUInt16(span[offset..], command.Version); | ||
offset += WireFormatting.WriteUInt32(span[offset..], _corrId); | ||
offset += WireFormatting.WriteString(span[offset..], _superStream); | ||
offset += WireFormatting.WriteInt32(span[offset..], _partitions.Count); | ||
foreach (var partition in _partitions) | ||
{ | ||
offset += WireFormatting.WriteString(span[offset..], partition); | ||
} | ||
|
||
offset += WireFormatting.WriteInt32(span[offset..], _bindingKeys.Count); | ||
foreach (var bindingKey in _bindingKeys) | ||
{ | ||
offset += WireFormatting.WriteString(span[offset..], bindingKey); | ||
} | ||
|
||
offset += WireFormatting.WriteInt32(span[offset..], _arguments.Count); | ||
foreach (var (key, value) in _arguments) | ||
{ | ||
offset += WireFormatting.WriteString(span[offset..], key); | ||
offset += WireFormatting.WriteString(span[offset..], value); | ||
} | ||
|
||
return offset; | ||
} | ||
} | ||
|
||
public readonly struct CreateSuperStreamResponse : ICommand | ||
{ | ||
public const ushort Key = 29; | ||
private readonly uint _correlationId; | ||
private readonly ushort _responseCode; | ||
|
||
private CreateSuperStreamResponse(uint correlationId, ushort responseCode) | ||
{ | ||
_correlationId = correlationId; | ||
_responseCode = responseCode; | ||
} | ||
|
||
public int SizeNeeded => throw new NotImplementedException(); | ||
|
||
public uint CorrelationId => _correlationId; | ||
|
||
public ResponseCode ResponseCode => (ResponseCode)_responseCode; | ||
|
||
public int Write(Span<byte> span) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
internal static int Read(ReadOnlySequence<byte> frame, out CreateSuperStreamResponse command) | ||
{ | ||
var offset = WireFormatting.ReadUInt16(frame, out _); | ||
offset += WireFormatting.ReadUInt16(frame.Slice(offset), out _); | ||
offset += WireFormatting.ReadUInt32(frame.Slice(offset), out var correlation); | ||
offset += WireFormatting.ReadUInt16(frame.Slice(offset), out var responseCode); | ||
command = new CreateSuperStreamResponse(correlation, responseCode); | ||
return offset; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// This source code is dual-licensed under the Apache License, version | ||
// 2.0, and the Mozilla Public License, version 2.0. | ||
// Copyright (c) 2017-2023 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. | ||
|
||
using System; | ||
using System.Buffers; | ||
|
||
namespace RabbitMQ.Stream.Client; | ||
|
||
internal readonly struct DeleteSuperStreamRequest : ICommand | ||
{ | ||
private readonly uint _correlationId; | ||
private readonly string _superStream; | ||
private const ushort Key = 30; | ||
|
||
public DeleteSuperStreamRequest(uint correlationId, string superStream) | ||
{ | ||
_correlationId = correlationId; | ||
_superStream = superStream; | ||
} | ||
|
||
public int SizeNeeded => 8 + WireFormatting.StringSize(_superStream); | ||
|
||
public int Write(Span<byte> span) | ||
{ | ||
var offset = WireFormatting.WriteUInt16(span, Key); | ||
offset += WireFormatting.WriteUInt16(span[offset..], ((ICommand)this).Version); | ||
offset += WireFormatting.WriteUInt32(span[offset..], _correlationId); | ||
offset += WireFormatting.WriteString(span[offset..], _superStream); | ||
return offset; | ||
} | ||
} | ||
|
||
public readonly struct DeleteSuperStreamResponse : ICommand | ||
{ | ||
public const ushort Key = 30; | ||
private readonly uint _correlationId; | ||
private readonly ushort _responseCode; | ||
|
||
public DeleteSuperStreamResponse(uint correlationId, ushort responseCode) | ||
{ | ||
_correlationId = correlationId; | ||
_responseCode = responseCode; | ||
} | ||
|
||
public int SizeNeeded => throw new NotImplementedException(); | ||
|
||
public uint CorrelationId => _correlationId; | ||
|
||
public ResponseCode ResponseCode => (ResponseCode)_responseCode; | ||
|
||
public int Write(Span<byte> span) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
internal static int Read(ReadOnlySequence<byte> frame, out DeleteSuperStreamResponse command) | ||
{ | ||
var offset = WireFormatting.ReadUInt16(frame, out _); | ||
offset += WireFormatting.ReadUInt16(frame.Slice(offset), out _); | ||
offset += WireFormatting.ReadUInt32(frame.Slice(offset), out var correlation); | ||
offset += WireFormatting.ReadUInt16(frame.Slice(offset), out var responseCode); | ||
command = new DeleteSuperStreamResponse(correlation, responseCode); | ||
return offset; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.