Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: yggdrasil #224

Merged
merged 35 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a46dc44
chore: yggdrasil
nunogois Jun 26, 2024
01b55bb
chore: target only net472 and up, plus other fixes
nunogois Jun 26, 2024
d9ee6f5
fix: make the tests build again
nunogois Jun 27, 2024
423a435
Update src/Unleash/Internal/UnleashServices.cs
nunogois Jun 27, 2024
7abfecd
fix: log failed initial takestates
nunogois Jun 27, 2024
89ee61d
refactor: UpgradeVariant instead of casting
nunogois Jun 27, 2024
4cc00a6
fix: trailing commas in test state
nunogois Jun 27, 2024
6045224
fix: test state serialization
nunogois Jun 27, 2024
10e10eb
fix: ToggleBootstrapFileProvider tests
nunogois Jun 27, 2024
00ecba4
fix: segments test state serialization
nunogois Jun 27, 2024
fea50e1
fix: tests state serialization
nunogois Jun 27, 2024
a37b0e4
yeet impression event test with wrong assumption
nunogois Jun 27, 2024
bfb2207
fix TogglesUpdated event test
nunogois Jun 27, 2024
af176fe
fix initial state assumption in test
nunogois Jun 27, 2024
a037b9a
fix initial state assumption
nunogois Jun 27, 2024
a6bed79
fix trailing commas in state
nunogois Jun 27, 2024
b546dd3
yeet tests that we consider no longer relevant
nunogois Jun 28, 2024
0e53fba
yeet irrelevant test, add new test to check error event loading inval…
nunogois Jun 28, 2024
c19153f
remove unnecessary assignment
nunogois Jun 28, 2024
a5c0b25
return empty string in mock instead of "mock" literal
nunogois Jun 28, 2024
60b60ce
fix property name in Variant constructor
nunogois Jun 28, 2024
aeb06c7
comment out RemoteAddressStrategyTest
nunogois Jun 28, 2024
7bc076c
set to string.Empty instead of null
nunogois Jun 28, 2024
92eb5cd
revert uncomment RemoteAddressStrategyTest
nunogois Jun 28, 2024
0b58560
test: assert bucket is not null
nunogois Jul 1, 2024
4c311d7
test: assert not null
nunogois Jul 1, 2024
bb96e15
fix: handle fetch features TakeState exceptions
nunogois Jul 3, 2024
c981ec8
fix: bring back metric skips
nunogois Jul 3, 2024
c72cdb3
style: dotnet format
nunogois Jul 11, 2024
f982a19
fix: extended metrics
nunogois Jul 11, 2024
4eb577b
refactor: misc cleanup
nunogois Jul 11, 2024
1372c36
refactor: using Yggdrasil for IStrategy
nunogois Jul 11, 2024
c3669e2
fix: re-add missing type
nunogois Jul 29, 2024
99748a6
tests: fix tests after rebase
nunogois Jul 29, 2024
5e2ee28
chore: merge main
sighphyre Oct 28, 2024
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
5 changes: 2 additions & 3 deletions src/Unleash/ClientFactory/IUnleashClientFactory.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
using System.Threading.Tasks;
using Unleash.Strategies;
using System.Threading.Tasks;
using Yggdrasil;

namespace Unleash.ClientFactory
{
public interface IUnleashClientFactory

Check warning on line 6 in src/Unleash/ClientFactory/IUnleashClientFactory.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'IUnleashClientFactory'

Check warning on line 6 in src/Unleash/ClientFactory/IUnleashClientFactory.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'IUnleashClientFactory'
{
IUnleash CreateClient(UnleashSettings settings, bool synchronousInitialization = false, params IStrategy[] strategies);
Task<IUnleash> CreateClientAsync(UnleashSettings settings, bool synchronousInitialization = false, params IStrategy[] strategies);
Expand Down
2 changes: 1 addition & 1 deletion src/Unleash/ClientFactory/UnleashClientFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Threading;
using System.Threading.Tasks;
using Unleash.Strategies;
using Yggdrasil;

namespace Unleash.ClientFactory
{
Expand Down
6 changes: 2 additions & 4 deletions src/Unleash/Communication/FetchTogglesResult.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using Unleash.Internal;

namespace Unleash.Communication
namespace Unleash.Communication
{
internal class FetchTogglesResult
{
public ToggleCollection ToggleCollection { get; set; }
public bool HasChanged { get; set; }
public string Etag { get; set; }
public string State { get; set; }
}
}
3 changes: 2 additions & 1 deletion src/Unleash/Communication/IUnleashApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ internal interface IUnleashApiClient
{
Task<FetchTogglesResult> FetchToggles(string etag, CancellationToken cancellationToken, bool throwOnFail = false);
Task<bool> RegisterClient(ClientRegistration registration, CancellationToken cancellationToken);
Task<bool> SendMetrics(ThreadSafeMetricsBucket metrics, CancellationToken cancellationToken);
// TODO: Can be simplified to `using Yggdrasil;` once MetricsBucket is dropped from Unleash.Metrics
Task<bool> SendMetrics(Yggdrasil.MetricsBucket metrics, CancellationToken cancellationToken);
}
}
25 changes: 10 additions & 15 deletions src/Unleash/Communication/UnleashApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,12 @@ private async Task<FetchTogglesResult> HandleSuccessResponse(HttpResponseMessage
{
HasChanged = false,
Etag = newEtag,
ToggleCollection = null,
};
}

var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
var toggleCollection = jsonSerializer.Deserialize<ToggleCollection>(stream);
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

if (toggleCollection == null)
if (string.IsNullOrEmpty(content))
{
return new FetchTogglesResult
{
Expand All @@ -177,7 +175,7 @@ private async Task<FetchTogglesResult> HandleSuccessResponse(HttpResponseMessage
{
HasChanged = true,
Etag = newEtag,
ToggleCollection = toggleCollection
State = content
};
}

Expand Down Expand Up @@ -212,7 +210,7 @@ public async Task<bool> RegisterClient(ClientRegistration registration, Cancella
}
}

public async Task<bool> SendMetrics(ThreadSafeMetricsBucket metrics, CancellationToken cancellationToken)
public async Task<bool> SendMetrics(Yggdrasil.MetricsBucket metrics, CancellationToken cancellationToken)
{
if (metricsRequestsToSkip > metricsRequestsSkipped)
{
Expand All @@ -226,16 +224,13 @@ public async Task<bool> SendMetrics(ThreadSafeMetricsBucket metrics, Cancellatio

var memoryStream = new MemoryStream();

using (metrics.StopCollectingMetrics(out var bucket))
jsonSerializer.Serialize(memoryStream, new ClientMetrics
{
jsonSerializer.Serialize(memoryStream, new ClientMetrics
{
AppName = clientRequestHeaders.AppName,
InstanceId = clientRequestHeaders.InstanceTag,
Bucket = bucket
});
memoryStream.Position = 0;
}
AppName = clientRequestHeaders.AppName,
InstanceId = clientRequestHeaders.InstanceTag,
Bucket = metrics
});
memoryStream.Position = 0;

const int bufferSize = 1024 * 4;

Expand Down
Loading
Loading