Skip to content

Commit

Permalink
Adds handling for tenant api fields
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherjturner committed Jan 10, 2025
1 parent e444a7b commit af1fdd6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ public record Service
[JsonPropertyName("test_suite")] public string? TestSuite { get; init; }
[JsonPropertyName("buckets")] public List<string>? Buckets { get; init; }
[JsonPropertyName("queues")] public List<string>? Queues { get; init; }
[JsonPropertyName("api_enabled")] public bool? ApiEnabled { get; init; }
[JsonPropertyName("api_type")] public string? ApiType { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ protected override List<CreateIndexModel<TenantServiceRecord>> DefineIndexes(
public async Task PersistEvent(Event<TenantServicesPayload> workflowEvent, CancellationToken cancellationToken)
{
var payload = workflowEvent.Payload;
_logger.LogInformation($"Persisting tenant services for environment: {payload.Environment}");
_logger.LogInformation("Persisting tenant services for environment: {Environment}", payload.Environment);

var tenantServices = payload.Services.Select(s => new TenantServiceRecord(payload.Environment, s.Name, s.Zone,
s.Mongo, s.Redis, s.ServiceCode, s.TestSuite, s.Buckets, s.Queues)).ToList();
s.Mongo, s.Redis, s.ServiceCode, s.TestSuite, s.Buckets, s.Queues, s.ApiEnabled, s.ApiType)).ToList();

var servicesInDb = await FindAllServicesInEnvironment(payload.Environment, cancellationToken);

Expand Down Expand Up @@ -125,7 +125,9 @@ public record TenantServiceRecord(
string ServiceCode,
string? TestSuite,
List<string>? Buckets,
List<string>? Queues)
List<string>? Queues,
bool? ApiEnabled,
string? ApiType)
{
[BsonId(IdGenerator = typeof(ObjectIdGenerator))]
[BsonIgnoreIfDefault]
Expand All @@ -142,6 +144,25 @@ public virtual bool Equals(TenantServiceRecord? other)
ServiceCode == other.ServiceCode &&
TestSuite == other.TestSuite &&
Buckets == other.Buckets &&
Queues == (other.Queues);
Queues == (other.Queues) &&
ApiEnabled == other.ApiEnabled &&
ApiType == other.ApiType;
}

public override int GetHashCode()
{
var hashCode = new HashCode();
hashCode.Add(Environment);
hashCode.Add(ServiceName);
hashCode.Add(Zone);
hashCode.Add(Mongo);
hashCode.Add(Redis);
hashCode.Add(ServiceCode);
hashCode.Add(TestSuite);
hashCode.Add(Buckets);
hashCode.Add(Queues);
hashCode.Add(ApiEnabled);
hashCode.Add(ApiType);
return hashCode.ToHashCode();
}
}

0 comments on commit af1fdd6

Please sign in to comment.