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
33 changes: 25 additions & 8 deletions SW.Bitween.Api/Data/BitweenDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.OnDelete(DeleteBehavior.Restrict);
bgr.HasOne(p => p.Partner).WithMany().HasForeignKey(p => p.PartnerId)
.IsRequired(false).OnDelete(DeleteBehavior.Restrict);
bgr.Property(p => p.MatchExpression).HasConversion(
domainObject =>
domainObject == null ? null : MatchSpecValueConverter.SerializeMatchSpec(domainObject),
dbString => dbString == null ? null : MatchSpecValueConverter.DeserializeMatchSpec(dbString));
bgr.Property(p => p.MatchExpression).HasMatchExpressionConversion();
});

modelBuilder.Entity<GlobalAdapterValuesSet>(gav =>
Expand Down Expand Up @@ -218,10 +215,29 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasConstraintName("FK_Subscriptions_AggFor").OnDelete(DeleteBehavior.Restrict);
b.HasOne(i => i.Category).WithMany().HasForeignKey(i => i.CategoryId);
b.HasOne(i => i.WorkGroup).WithMany().HasForeignKey(i => i.WorkGroupId);
b.Property(p => p.MatchExpression).HasConversion(
domainObject =>
domainObject == null ? null : MatchSpecValueConverter.SerializeMatchSpec(domainObject),
dbString => dbString == null ? null : MatchSpecValueConverter.DeserializeMatchSpec(dbString));
b.HasOne(i => i.RetryPolicy).WithMany().HasForeignKey(i => i.RetryPolicyId).IsRequired(false)
.OnDelete(DeleteBehavior.SetNull);
b.Property(p => p.CustomRetryPolicy).StoreAsJson();
b.Property(p => p.MatchExpression).HasMatchExpressionConversion();
});

modelBuilder.Entity<RetryPolicy>(b =>
{
b.ToTable("RetryPolicies");
b.HasKey(p => p.Id);
b.Property(p => p.Id).ValueGeneratedOnAdd();
b.Property(p => p.Name).IsRequired().HasMaxLength(200);
b.Property(p => p.Groups).StoreAsJson();
});

modelBuilder.Entity<DelayedRetry>(b =>
{
b.ToTable("DelayedRetries");
b.HasKey(p => p.Id);
b.Property(p => p.Id).IsUnicode(false).HasMaxLength(50);
b.Property(p => p.On);
b.Property(p => p.GroupAttemptCounts).StoreAsJson();
b.HasIndex(p => p.On);
});

modelBuilder.Entity<Xchange>(b =>
Expand All @@ -236,6 +252,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
b.Property(p => p.HandlerId).HasMaxLength(200).IsUnicode(false);
b.Property(p => p.HandlerProperties).StoreAsJson();
b.Property(p => p.MapperProperties).StoreAsJson();
b.Property(p => p.GroupAttemptCounts).StoreAsJson();
b.Property(p => p.InputContentType).IsUnicode(false).HasMaxLength(200);
b.Property(p => p.ResponseMessageTypeName).IsUnicode(false).HasMaxLength(500);

Expand Down
11 changes: 11 additions & 0 deletions SW.Bitween.Api/Domain/DelayedRetry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using SW.PrimitiveTypes;

namespace SW.Bitween.Domain;
// Id should be the same for xchangeId when retry happens the record is deleted
public class DelayedRetry : BaseEntity<string>
{
public DateTime On { get; set; }
public Dictionary<string, int> GroupAttemptCounts { get; set; } = new();
}
67 changes: 34 additions & 33 deletions SW.Bitween.Api/Domain/Notifier.cs
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
using System.Collections.Generic;
using System.Runtime.Intrinsics.X86;
using SW.PrimitiveTypes;

namespace SW.Bitween.Domain

namespace SW.Bitween.Domain;

public class Notifier:BaseEntity
{
public class Notifier:BaseEntity
{

public Notifier(string name)
{
Name = name;
Inactive = false;
}
public Notifier(string name)
{
Name = name;
Inactive = false;
}

public string Name { get; set; }
public bool RunOnSuccessfulResult { get; set; }
public bool RunOnBadResult { get; set; }
public bool RunOnFailedResult { get; set; }
public string HandlerId { get; set; }
public bool Inactive { get; set; }
public IReadOnlyDictionary<string, string> HandlerProperties { get; private set; }
public string Name { get; set; }
public bool RunOnSuccessfulResult { get; set; }
public bool RunOnBadResult { get; set; }
public bool RunOnFailedResult { get; set; }
public string HandlerId { get; set; }
public bool Inactive { get; set; }
public IReadOnlyDictionary<string, string> HandlerProperties { get; private set; }

public int[] RunOnSubscriptions { get; set; }
public int[] RunOnSubscriptions { get; set; }

public void Update(string name, bool runOnSuccessfulResult, bool runOnBadResult, bool runOnFailedResult, string handlerId,bool inactive, int[] runOnSubscriptions)
{
Name = name;
RunOnSuccessfulResult = runOnSuccessfulResult;
RunOnBadResult = runOnBadResult;
RunOnFailedResult = runOnFailedResult;
HandlerId = handlerId;
Inactive = inactive;
RunOnSubscriptions = runOnSubscriptions;
}
public void SetDictionaries(
IReadOnlyDictionary<string, string> handler
)
{
HandlerProperties = handler;
}
public void Update(string name, bool runOnSuccessfulResult, bool runOnBadResult, bool runOnFailedResult, string handlerId,bool inactive, int[] runOnSubscriptions)
{
Name = name;
RunOnSuccessfulResult = runOnSuccessfulResult;
RunOnBadResult = runOnBadResult;
RunOnFailedResult = runOnFailedResult;
HandlerId = handlerId;
Inactive = inactive;
RunOnSubscriptions = runOnSubscriptions;
}
public void SetDictionaries(
IReadOnlyDictionary<string, string> handler
)
{
HandlerProperties = handler;
}




}
}
16 changes: 16 additions & 0 deletions SW.Bitween.Api/Domain/RetryPolicy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using SW.Bitween.Model;
using SW.PrimitiveTypes;

namespace SW.Bitween.Domain;
// templates of retry policy to choose on subscriptions
public class RetryPolicy : BaseEntity, IAudited, IRetryPolicy
{
public string Name { get; set; }
public List<RetryGroup> Groups { get; set; } = [];
public DateTime CreatedOn { get; set; }
public string CreatedBy { get; set; }
public DateTime? ModifiedOn { get; set; }
public string ModifiedBy { get; set; }
}
Loading