Skip to content

Commit

Permalink
Use streaming endpoint for contents.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Nov 10, 2024
1 parent 42b1512 commit aa23fd0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cli/Squidex.CLI/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
<PackageTags>Squidex HeadlessCMS</PackageTags>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>13.4</Version>
<Version>13.6</Version>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Task SaveAsync()
});
}

await client.GetAllAsync(async content =>
async Task HandleContentAsync(DynamicContent content)
{
if (content.LastModified < options.MaxAgeDate)
{
Expand All @@ -96,7 +96,16 @@ await client.GetAllAsync(async content =>
contents.Clear();
contentBatch++;
}
}, context: context);
}

if (options.StreamContents)
{
await client.StreamAllAsync(HandleContentAsync, context: context);
}
else
{
await client.GetAllAsync(HandleContentAsync, context: context);
}

if (contents.Count > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public async Task ImportAsync(ISyncService sync, SyncOptions options, ISession s
{
foreach (var name in current.Items.Select(x => x.Name))
{
if (createModels.All(x => x.Name != name))
if (createModels.TrueForAll(x => x.Name != name))
{
await log.DoSafeAsync($"Schema {name} deleting", async () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public sealed class SyncOptions

public bool Recreate { get; set; }

public bool StreamContents { get; set; }

public bool UpdateCurrentClient { get; set; }

public DateTimeOffset MaxAgeDate { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public async Task ImportAsync(ISyncService sync, SyncOptions options, ISession s
{
foreach (var (name, workflow) in workflowsByName.ToList())
{
if (models.All(x => x.Name == name))
if (models.TrueForAll(x => x.Name == name))
{
await log.DoSafeAsync($"Workflow '{name}' deleting", async () =>
{
Expand Down
10 changes: 9 additions & 1 deletion cli/Squidex.CLI/Squidex.CLI/Commands/App_Sync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ public sealed class OutArguments : AppArguments
[Option('t', "targets", Description = "The targets to sync, e.g. ‘sync out -t contents -t schemas’. Use 'sync targets' to view all targets.")]
public string[] Targets { get; set; }

[Option("stream-contents", Description = "Use the new streaming API for contents.")]
public bool StreamContents { get; set; }

[Option("max-age", Description = "Content & assets created or last modified within time span defined.")]
public TimeSpan? MaxAge { get; set; }

Expand All @@ -164,7 +167,12 @@ public sealed class OutArguments : AppArguments

public SyncOptions ToOptions()
{
return new SyncOptions { Targets = Targets, MaxAgeDate = GetMaxAgeDate() };
return new SyncOptions
{
Targets = Targets,
MaxAgeDate = GetMaxAgeDate(),
StreamContents = StreamContents
};
}

public sealed class Validator : AbstractValidator<OutArguments>
Expand Down

0 comments on commit aa23fd0

Please sign in to comment.