Skip to content

Commit

Permalink
feat: adapted to changes in evitaDB (histogram changes, inSet constra…
Browse files Browse the repository at this point in the history
…int change), removed client context for tracing, replaced with OpenTelemetry capabilities, updated zip library and dotnet path in github actions config
  • Loading branch information
tpz committed Feb 1, 2024
1 parent 5a45680 commit 244d281
Show file tree
Hide file tree
Showing 23 changed files with 361 additions and 365 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
ref: ${{ github.head_ref }}
fetch-depth: 0

# in future updates of dotnet-version property, don't forget propagate this change into query validator publishing folder path
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
Expand Down Expand Up @@ -62,17 +63,17 @@ jobs:
dotnet publish -r win-x64 -c Release -p:PublishSingleFile=true --self-contained false
- name: Zip
uses: vimtor/action-zip@v1
uses: vimtor/action-zip@v1.1
with:
dest: 'Validator.zip'
files: 'EvitaDB.QueryValidator/bin/Release/net7.0/linux-x64/publish/Validator'
files: 'EvitaDB.QueryValidator/bin/Release/net8.0/linux-x64/publish/Validator'
recursive: true

- name: Zip
uses: vimtor/action-zip@v1
uses: vimtor/action-zip@v1.1
with:
dest: 'Validator-win.zip'
files: 'EvitaDB.QueryValidator/bin/Release/net7.0/win-x64/publish/Validator.exe'
files: 'EvitaDB.QueryValidator/bin/Release/net8.0/win-x64/publish/Validator.exe'
recursive: true

- name: Pack nuget
Expand Down
21 changes: 18 additions & 3 deletions EvitaDB.Client/Config/EvitaClientConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ namespace EvitaDB.Client.Config;
public record EvitaClientConfiguration(
string ClientId, string Host, int Port, int SystemApiPort, bool UseGeneratedCertificate,
bool UsingTrustedRootCaCertificate, bool MtlsEnabled, string? ServerCertificatePath, string? CertificateFileName,
string? CertificateKeyFileName, string? CertificateKeyPassword, string? CertificateFolderPath
string? CertificateKeyFileName, string? CertificateKeyPassword, string? CertificateFolderPath, string? TraceEndpointUrl,
string? TraceEndpointProtocol
)
{
private const int DefaultGrpcApiPort = 5556;
Expand All @@ -26,6 +27,8 @@ public class Builder
private string? CertificateKeyFileName { get; set; }
private string? CertificateKeyPassword { get; set; }
private string? CertificateFolderPath { get; set; }
private string? TraceEndpointUrl { get; set; }
private string? TraceEndpointProtocol { get; set; }

public Builder()
{
Expand Down Expand Up @@ -110,15 +113,27 @@ public Builder SetCertificateFolderPath(string certificateFolderPath)
CertificateFolderPath = certificateFolderPath;
return this;
}

public Builder SetTraceEndpointUrl(string traceEndpointUrl)
{
TraceEndpointUrl = traceEndpointUrl;
return this;
}

public Builder SetTraceEndpointProtocol(string traceEndpointProtocol)
{
TraceEndpointProtocol = traceEndpointProtocol;
return this;
}

public EvitaClientConfiguration Build()
{
return new EvitaClientConfiguration(
ClientId, Host, Port, SystemApiPort, UseGeneratedCertificate, UsingTrustedRootCaCertificate,
MtlsEnabled,
ServerCertificatePath, CertificateFileName, CertificateKeyFileName,
CertificateKeyPassword, CertificateFolderPath
CertificateKeyPassword, CertificateFolderPath, TraceEndpointUrl, TraceEndpointProtocol
);
}
}
}
}
18 changes: 18 additions & 0 deletions EvitaDB.Client/Converters/Models/EvitaEnumConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,15 @@ public static GrpcCardinality ToGrpcCardinality(Cardinality? cardinality)
_ => throw new ArgumentOutOfRangeException(nameof(cardinality), cardinality, null)
};
}

public static HistogramBehavior ToHistogramBehavior(GrpcHistogramBehavior grpcHistogramBehavior) {
return grpcHistogramBehavior switch
{
GrpcHistogramBehavior.Standard => HistogramBehavior.Standard,
GrpcHistogramBehavior.Optimized => HistogramBehavior.Optimized,
_ => throw new EvitaInternalError("Unrecognized remote histogram behavior: " + grpcHistogramBehavior)
};
}

public static CatalogEvolutionMode ToCatalogEvolutionMode(GrpcCatalogEvolutionMode grpcEvolutionMode)
{
Expand Down Expand Up @@ -526,4 +535,13 @@ public static GrpcGlobalAttributeUniquenessType ToGrpcGlobalAttributeUniquenessT
_ => throw new EvitaInternalError("Unrecognized global attribute uniqueness type: " + globalAttributeUniquenessType)
};
}

public static GrpcHistogramBehavior ToGrpcHistogramBehavior(HistogramBehavior histogramBehavior) {
return histogramBehavior switch
{
HistogramBehavior.Standard => GrpcHistogramBehavior.Standard,
HistogramBehavior.Optimized => GrpcHistogramBehavior.Optimized,
_ => throw new EvitaInternalError("Unrecognized histogram behavior: " + histogramBehavior)
};
}
}
1 change: 0 additions & 1 deletion EvitaDB.Client/Converters/Models/ResponseConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ private static IHistogram ToHistogram(GrpcHistogram grpcHistogram)
private static Bucket ToBucket(GrpcHistogram.Types.GrpcBucket grpcBucket)
{
return new Bucket(
grpcBucket.Index,
EvitaDataTypesConverter.ToDecimal(grpcBucket.Threshold),
grpcBucket.Occurrences,
grpcBucket.Requested
Expand Down
26 changes: 24 additions & 2 deletions EvitaDB.Client/Converters/Queries/QueryConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using EvitaDB.Client.Queries.Order;
using EvitaDB.Client.Queries.Requires;

namespace EvitaDB.Client.Utils;
namespace EvitaDB.Client.Converters.Queries;

public class QueryConverter
public static class QueryConverter
{
public static List<object> ConvertQueryParamsList(List<GrpcQueryParam> queryParams)
{
Expand Down Expand Up @@ -123,6 +123,11 @@ public static object ConvertQueryParam(GrpcQueryParam queryParam)
{
return EvitaEnumConverter.ToStatisticsType(queryParam.StatisticsType);
}

if (queryParam.QueryParamCase == GrpcQueryParam.QueryParamOneofCase.HistogramBehavior)
{
return EvitaEnumConverter.ToHistogramBehavior(queryParam.HistogramBehavior);
}

if (queryParam.QueryParamCase == GrpcQueryParam.QueryParamOneofCase.StringArrayValue)
{
Expand Down Expand Up @@ -239,6 +244,13 @@ public static object ConvertQueryParam(GrpcQueryParam queryParam)
.Select(EvitaEnumConverter.ToStatisticsType)
.ToArray();
}

if (queryParam.QueryParamCase == GrpcQueryParam.QueryParamOneofCase.HistogramBehaviorTypeArrayValue) {
return queryParam.HistogramBehaviorTypeArrayValue
.Value
.Select(EvitaEnumConverter.ToHistogramBehavior)
.ToArray();
}

throw new EvitaInvalidUsageException("Unsupported Evita data type `" + queryParam + "` in gRPC API.");
}
Expand Down Expand Up @@ -357,6 +369,10 @@ public static GrpcQueryParam ConvertQueryParam(object parameter)
{
queryParam.StatisticsType = EvitaEnumConverter.ToGrpcStatisticsType(statisticsType);
}
else if (parameter is HistogramBehavior histogramBehavior)
{
queryParam.HistogramBehavior = EvitaEnumConverter.ToGrpcHistogramBehavior(histogramBehavior);
}

else if (parameter is string[] stringArrayValue)
{
Expand Down Expand Up @@ -484,6 +500,12 @@ public static GrpcQueryParam ConvertQueryParam(object parameter)
queryParam.StatisticsTypeArrayValue = new GrpcStatisticsTypeArray
{Value = {statisticsTypeArray.Select(EvitaEnumConverter.ToGrpcStatisticsType)}};
}
else if (parameter is HistogramBehavior[] histogramBehaviorArray)
{
queryParam.HistogramBehaviorTypeArrayValue = new GrpcHistogramBehaviorTypeArray()
{Value = {histogramBehaviorArray.Select(EvitaEnumConverter.ToGrpcHistogramBehavior)}};
}

else
{
throw new EvitaInvalidUsageException("Unsupported Evita data type `" + parameter.GetType().Name + "` in gRPC API.");
Expand Down
Loading

0 comments on commit 244d281

Please sign in to comment.