Skip to content

Commit

Permalink
Refactor StreamContext interface (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-vitaliy authored Oct 16, 2024
1 parent 2acd2fc commit d09ec13
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Services/Base/IStreamContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ public interface IStreamContext
/// <summary>
/// Stream metadata that can be used by the stream consumer.
/// </summary>
Option<StreamMetadata> StreamMetadata { get; }
Option<StreamMetadata> GetStreamMetadata();
}
25 changes: 25 additions & 0 deletions src/Sinks/Extensions/StreamPartitionExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Arcane.Framework.Services.Models;
using Arcane.Framework.Sinks.Models;

namespace Arcane.Framework.Sinks.Extensions;

/// <summary>
/// Extension methods for StreamPartition class
/// </summary>
public static class StreamPartitionExtensions
{
/// <summary>
/// Converts a PartitionsMetadataDefinition to a StreamPartition
/// </summary>
/// <param name="partition"></param>
/// <returns></returns>
public static StreamPartition ToStreamPartition(this PartitionsMetadataDefinition partition)
{
return new StreamPartition
{
Name = partition.Name,
FieldName = partition.FieldName,
FieldFormat = partition.FieldFormat
};
}
}
2 changes: 1 addition & 1 deletion test/Providers/TestCases/TestStreamContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class TestStreamContext : IStreamContext, IStreamContextWriter
public string StreamId => nameof(StreamId);
public bool IsBackfilling => false;
public string StreamKind => nameof(StreamKind);
public Option<StreamMetadata> StreamMetadata => Option<StreamMetadata>.None;
public Option<StreamMetadata> GetStreamMetadata() => new();

public void SetStreamId(string streamId)
{
Expand Down

0 comments on commit d09ec13

Please sign in to comment.