Skip to content

Commit

Permalink
#813 StoreQueryArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhabis committed Feb 17, 2023
1 parent 8132801 commit 03969fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ public async Task<IEnumerable<FiberInfo>> GetFiberListAsync(FiberFilter filter)

var result = new List<FiberInfo>();

var queryArgs = new StoreQueryArgs(filter);
var totalShards = shards.Count();

var queryArgs = new StoreQueryArgs(filter, totalShards);

foreach(var batch in shards.BatchBy(4))
{
Expand Down
19 changes: 16 additions & 3 deletions src/Azos.Sky.Server/Fabric/Server/StoreQueryArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,25 @@ namespace Azos.Sky.Fabric
public sealed class StoreQueryArgs : TransientModel
{
public StoreQueryArgs() { }
public StoreQueryArgs(FiberFilter proto)
public StoreQueryArgs(FiberFilter filter, int totalShards)
{
proto.CopyFields(this);
if (proto.Id.HasValue) this.Gdid = proto.Id.Value.Gdid;
const int MAX_RECORDS = 512;

filter.CopyFields(this);
if (filter.Id.HasValue) this.Gdid = filter.Id.Value.Gdid;

if (totalShards < 1) totalShards = 1;

var rc = (filter.PagingCount > 0 ? filter.PagingCount : MAX_RECORDS ) / totalShards;

rc = rc.KeepBetween(1, (MAX_RECORDS / totalShards).AtMinimum(1));

RecordCount = rc;
}

[Field(Description = "How many records to return")]
public int RecordCount { get; set; }

[Field(Description = "Gdid of the specific fiber or zero")]
public GDID? Gdid { get; set; }

Expand Down

0 comments on commit 03969fb

Please sign in to comment.