Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Assets/cortex-all.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions Cortex.sln
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cortex.Streams.MongoDb", "s
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cortex.Streams.Elasticsearch", "src\Cortex.Streams.Elasticsearch\Cortex.Streams.Elasticsearch.csproj", "{4D1F117D-48D7-47AD-9DAC-3B2DB45E628A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cortex.Types", "src\Cortex.Types\Cortex.Types.csproj", "{64E12D4C-FBB2-4004-8316-C886CBFC614B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -164,6 +166,10 @@ Global
{4D1F117D-48D7-47AD-9DAC-3B2DB45E628A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D1F117D-48D7-47AD-9DAC-3B2DB45E628A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D1F117D-48D7-47AD-9DAC-3B2DB45E628A}.Release|Any CPU.Build.0 = Release|Any CPU
{64E12D4C-FBB2-4004-8316-C886CBFC614B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64E12D4C-FBB2-4004-8316-C886CBFC614B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64E12D4C-FBB2-4004-8316-C886CBFC614B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64E12D4C-FBB2-4004-8316-C886CBFC614B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![Cortex](./Assets/cortex-all.svg)

# Cortex Data Framework

**Cortex Data Framework** is a robust, extensible platform designed to facilitate real-time data streaming, processing, and state management. It provides developers with a comprehensive suite of tools and libraries to build scalable, high-performance data pipelines tailored to diverse use cases. By abstracting underlying streaming technologies and state management solutions, Cortex Data Framework enables seamless integration, simplified development workflows, and enhanced maintainability for complex data-driven applications.
Expand Down Expand Up @@ -114,6 +116,9 @@
- **Cortex.Telemetry.OpenTelemetry:** Adds support for Open Telemetry.
[![NuGet Version](https://img.shields.io/nuget/v/Cortex.Telemetry.OpenTelemetry?label=Cortex.Telemetry.OpenTelemetry)](https://www.nuget.org/packages/Cortex.Telemetry.OpenTelemetry)

- **Cortex.Types:** Use complex types like OneOf, AllOf and AnyOf
[![NuGet Version](https://img.shields.io/nuget/v/Cortex.Types?label=Cortex.Types)](https://www.nuget.org/packages/Cortex.Types)


## Getting Started

Expand Down
Binary file modified src/Cortex.Mediator/Assets/andyX.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.States.Cassandra/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.States.ClickHouse/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.States.MSSqlServer/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.States.MongoDb/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.States.PostgreSQL/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.States.RocksDb/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.States.SQLite/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.States/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Streams.AWSSQS/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Streams.AzureBlobStorage/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Streams.AzureServiceBus/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Streams.Elasticsearch/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Streams.Files/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Streams.Http/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Streams.Kafka/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Streams.MSSqlServer/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Streams.MongoDb/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Streams.PostgreSQL/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Streams.Pulsar/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Streams.RabbitMQ/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Streams.S3/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Streams/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Telemetry.OpenTelemetry/Assets/cortex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Cortex.Telemetry/Assets/cortex.png
70 changes: 70 additions & 0 deletions src/Cortex.Types/AllOf/AllOf1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Diagnostics.CodeAnalysis;

namespace Cortex.Types
{
/// <summary>
/// Represents a value that is all of the specified types. The value must be compatible with each of the type parameters.
/// </summary>
/// <typeparam name="T1">First required type</typeparam>
/// <typeparam name="T2">Second required type</typeparam>
public readonly struct AllOf<T1> : IEquatable<AllOf<T1>>, IAllOf
{
private readonly object _value;

/// <inheritdoc />
public object Value => _value;

private AllOf(object value)
{
if (!(value is T1))
throw new ArgumentException($"Value must be compatible with {typeof(T1).Name}.");
_value = value;
}

/// <summary>
/// Creates an AllOf instance from a value that is compatible with all type parameters.
/// </summary>
/// <typeparam name="T">Type of the value which must implement all type parameters</typeparam>
public static AllOf<T1> Create<T>(T value) where T : T1 => new AllOf<T1>(value);


// For now we are skipping the implicit operations
//public static implicit operator AllOf<T1>(T1 value)
//{
// if (value is T1)
// return new AllOf<T1>(value);
// throw new InvalidCastException($"{typeof(T1).Name} is not compatible.");
//}



public bool Is<T>() => _value is T;

public T As<T>()
{
if (_value is T val) return val;
throw new InvalidCastException($"Cannot cast {_value?.GetType().Name} to {typeof(T).Name}.");
}

public bool TryGet<T>([NotNullWhen(true)] out T result)
{
if (_value is T val)
{
result = val;
return true;
}
result = default!;
return false;
}

public bool Equals(AllOf<T1> other) => Equals(_value, other._value);
public override bool Equals(object obj) => obj is AllOf<T1> other && Equals(other);
public override int GetHashCode() => _value?.GetHashCode() ?? 0;

public static bool operator ==(AllOf<T1> left, AllOf<T1> right) => left.Equals(right);
public static bool operator !=(AllOf<T1> left, AllOf<T1> right) => !left.Equals(right);

public override string ToString() => _value?.ToString() ?? string.Empty;
}
}
75 changes: 75 additions & 0 deletions src/Cortex.Types/AllOf/AllOf2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System;
using System.Diagnostics.CodeAnalysis;

namespace Cortex.Types
{
/// <summary>
/// Represents a value that is all of the specified types. The value must be compatible with each of the type parameters.
/// </summary>
/// <typeparam name="T1">First required type</typeparam>
/// <typeparam name="T2">Second required type</typeparam>
public readonly struct AllOf<T1, T2> : IEquatable<AllOf<T1, T2>>, IAllOf
{
private readonly object _value;

/// <inheritdoc />
public object Value => _value;

private AllOf(object value)
{
if (!(value is T1) || !(value is T2))
throw new ArgumentException($"Value must be compatible with {typeof(T1).Name} and {typeof(T2).Name}.");
_value = value;
}

/// <summary>
/// Creates an AllOf instance from a value that is compatible with all type parameters.
/// </summary>
/// <typeparam name="T">Type of the value which must implement all type parameters</typeparam>
public static AllOf<T1, T2> Create<T>(T value) where T : T1, T2 => new AllOf<T1, T2>(value);


// For now we are skipping the implicit operations
//public static implicit operator AllOf<T1, T2>(T1 value)
//{
// if (value is T2)
// return new AllOf<T1, T2>(value);
// throw new InvalidCastException($"{typeof(T1).Name} is not compatible with {typeof(T2).Name}.");
//}

//public static implicit operator AllOf<T1, T2>(T2 value)
//{
// if (value is T1)
// return new AllOf<T1, T2>(value);
// throw new InvalidCastException($"{typeof(T2).Name} is not compatible with {typeof(T1).Name}.");
//}

public bool Is<T>() => _value is T;

public T As<T>()
{
if (_value is T val) return val;
throw new InvalidCastException($"Cannot cast {_value?.GetType().Name} to {typeof(T).Name}.");
}

public bool TryGet<T>([NotNullWhen(true)] out T result)
{
if (_value is T val)
{
result = val;
return true;
}
result = default!;
return false;
}

public bool Equals(AllOf<T1, T2> other) => Equals(_value, other._value);
public override bool Equals(object obj) => obj is AllOf<T1, T2> other && Equals(other);
public override int GetHashCode() => _value?.GetHashCode() ?? 0;

public static bool operator ==(AllOf<T1, T2> left, AllOf<T1, T2> right) => left.Equals(right);
public static bool operator !=(AllOf<T1, T2> left, AllOf<T1, T2> right) => !left.Equals(right);

public override string ToString() => _value?.ToString() ?? string.Empty;
}
}
83 changes: 83 additions & 0 deletions src/Cortex.Types/AllOf/AllOf3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System;
using System.Diagnostics.CodeAnalysis;

namespace Cortex.Types
{
/// <summary>
/// Represents a value that is all of the specified types. The value must be compatible with each of the type parameters.
/// </summary>
/// <typeparam name="T1">First required type</typeparam>
/// <typeparam name="T2">Second required type</typeparam>
/// <typeparam name="T3">Third required type</typeparam>
public readonly struct AllOf<T1, T2, T3> : IEquatable<AllOf<T1, T2, T3>>, IAllOf
{
private readonly object _value;

/// <inheritdoc />
public object Value => _value;

private AllOf(object value)
{
if (!(value is T1) || !(value is T2) || !(value is T3))
throw new ArgumentException($"Value must be compatible with {typeof(T1).Name}, {typeof(T2).Name}, and {typeof(T3).Name}.");
_value = value;
}

/// <summary>
/// Creates an AllOf instance from a value that is compatible with all type parameters.
/// </summary>
/// <typeparam name="T">Type of the value which must implement all type parameters</typeparam>
public static AllOf<T1, T2, T3> Create<T>(T value) where T : T1, T2, T3 => new AllOf<T1, T2, T3>(value);


// For now we are skipping the implicit operations
//public static implicit operator AllOf<T1, T2, T3>(T1 value)
//{
// if (value is T2 && value is T3)
// return new AllOf<T1, T2, T3>(value);
// throw new InvalidCastException($"{typeof(T1).Name} is not compatible with all required types.");
//}

//public static implicit operator AllOf<T1, T2, T3>(T2 value)
//{
// if (value is T1 && value is T3)
// return new AllOf<T1, T2, T3>(value);
// throw new InvalidCastException($"{typeof(T2).Name} is not compatible with all required types.");
//}

//public static implicit operator AllOf<T1, T2, T3>(T3 value)
//{
// if (value is T1 && value is T2)
// return new AllOf<T1, T2, T3>(value);
// throw new InvalidCastException($"{typeof(T3).Name} is not compatible with all required types.");
//}

public bool Is<T>() => _value is T;

public T As<T>()
{
if (_value is T val) return val;
throw new InvalidCastException($"Cannot cast {_value?.GetType().Name} to {typeof(T).Name}.");
}

public bool TryGet<T>([NotNullWhen(true)] out T result)
{
if (_value is T val)
{
result = val;
return true;
}
result = default!;
return false;
}

public bool Equals(AllOf<T1, T2, T3> other) => Equals(_value, other._value);
public override bool Equals(object obj) => obj is AllOf<T1, T2, T3> other && Equals(other);
public override int GetHashCode() => _value?.GetHashCode() ?? 0;

public static bool operator ==(AllOf<T1, T2, T3> left, AllOf<T1, T2, T3> right) => left.Equals(right);
public static bool operator !=(AllOf<T1, T2, T3> left, AllOf<T1, T2, T3> right) => !left.Equals(right);

public override string ToString() => _value?.ToString() ?? string.Empty;
}
}
13 changes: 13 additions & 0 deletions src/Cortex.Types/AllOf/IAllOf.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Cortex.Types
{
/// <summary>
/// Base interface for all AllOf types providing common functionality
/// </summary>
public interface IAllOf
{
/// <summary>
/// Gets the boxed value stored in the AllOf container
/// </summary>
object Value { get; }
}
}
Loading