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
2 changes: 1 addition & 1 deletion Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Create-ArtifactDir

function Publish-Archives($version)
{
$rids = $([xml](Get-Content .\src\SeqCli\SeqCli.csproj)).Project.PropertyGroup.RuntimeIdentifiers.Split(';')
$rids = $([xml](Get-Content .\src\SeqCli\SeqCli.csproj)).Project.PropertyGroup.RuntimeIdentifiers[0].Split(';')
foreach ($rid in $rids) {
$tfm = $framework
if ($rid -eq "win-x64") {
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Apps/Hosting/AppContainer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/App/InstallCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/App/UpdateCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Bench/BenchCasesCollection.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Bench/BenchCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Bench/QueryBenchCase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Bench/QueryBenchCaseTimings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
3 changes: 0 additions & 3 deletions src/SeqCli/Cli/Commands/Forwarder/InstallCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@
using System.Threading.Tasks;
using SeqCli.Forwarder.Cli.Features;
using SeqCli.Forwarder.Util;
using SeqCli;
using SeqCli.Cli;
using SeqCli.Cli.Features;
using SeqCli.Config;
using SeqCli.Config.Forwarder;
using SeqCli.Forwarder.ServiceProcess;
using SeqCli.Forwarder.Util;

// ReSharper disable once ClassNeverInstantiated.Global

Expand Down
1 change: 1 addition & 0 deletions src/SeqCli/Cli/Commands/Forwarder/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
using Serilog.Formatting.Compact;

#if WINDOWS
using System.Security.Cryptography.X509Certificates;
using SeqCli.Forwarder.ServiceProcess;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Forwarder/StartCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd
// Copyright © Datalust Pty Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Forwarder/StopCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd
// Copyright © Datalust Pty Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
3 changes: 1 addition & 2 deletions src/SeqCli/Cli/Commands/Forwarder/UninstallCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd
// Copyright © Datalust Pty Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,6 @@
using SeqCli.Forwarder.Util;
using SeqCli.Cli;
using SeqCli.Forwarder.ServiceProcess;
using SeqCli.Forwarder.Util;

namespace SeqCli.Forwarder.Cli.Commands
{
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Node/DemoteCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Node/HealthCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Node/ListCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Sample/IngestCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Sample/SetupCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Settings/ClearCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Settings/NamesCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Settings/SetCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Commands/Settings/ShowCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd and Contributors
// Copyright © Datalust Pty Ltd and Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
6 changes: 5 additions & 1 deletion src/SeqCli/Cli/Features/StoragePathFeature.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using System;
using System.IO;

#if WINDOWS
using SeqCli.Forwarder.ServiceProcess;
#endif

namespace SeqCli.Cli.Features;

class StoragePathFeature : CommandFeature
Expand Down Expand Up @@ -48,7 +52,7 @@ static string GetDefaultStorageRoot()
static string? TryQueryInstalledStorageRoot()
{
#if WINDOWS
if (SeqCli.Forwarder.Util.ServiceConfiguration.GetServiceStoragePath(
if (Forwarder.Util.ServiceConfiguration.GetServiceStoragePath(
SeqCliForwarderWindowsService.WindowsServiceName, out var storage))
return storage;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/SeqCli/Cli/Features/TimeoutFeature.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Datalust Pty Ltd
// Copyright © Datalust Pty Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
using System.Threading.Channels;
using System.Threading.Tasks;

namespace SeqCli.Forwarder.Storage;
namespace SeqCli.Forwarder.Channel;

class LogBuffer
class LogChannel
{
public LogBuffer(Func<CancellationToken, Task> write, CancellationToken cancellationToken)
public LogChannel(Func<CancellationToken, Task> write, CancellationToken cancellationToken)
{
var channel = Channel.CreateBounded<LogBufferEntry>(new BoundedChannelOptions(5)
var channel = System.Threading.Channels.Channel.CreateBounded<LogChannelEntry>(new BoundedChannelOptions(5)
{
SingleReader = false,
SingleWriter = true,
Expand All @@ -35,7 +35,7 @@ public LogBuffer(Func<CancellationToken, Task> write, CancellationToken cancella
}, cancellationToken: _shutdownTokenSource.Token);
}

readonly ChannelWriter<LogBufferEntry> _writer;
readonly ChannelWriter<LogChannelEntry> _writer;
readonly Task _worker;
readonly CancellationTokenSource _shutdownTokenSource;

Expand All @@ -44,7 +44,7 @@ public async Task WriteAsync(byte[] storage, Range range, CancellationToken canc
var tcs = new TaskCompletionSource();
using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _shutdownTokenSource.Token);

await _writer.WriteAsync(new LogBufferEntry(storage, range, tcs), cts.Token);
await _writer.WriteAsync(new LogChannelEntry(storage, range, tcs), cts.Token);
await tcs.Task;
}

Expand Down
6 changes: 6 additions & 0 deletions src/SeqCli/Forwarder/Channel/LogChannelEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using System;
using System.Threading.Tasks;

namespace SeqCli.Forwarder.Channel;

public readonly record struct LogChannelEntry(byte[] Storage, Range Range, TaskCompletionSource Completion);
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
using System.Threading.Tasks;
using Serilog;

namespace SeqCli.Forwarder.Storage;
namespace SeqCli.Forwarder.Channel;

class LogBufferMap
class LogChannelMap
{
public LogBufferMap()
public LogChannelMap()
{

}

public LogBuffer Get(string? apiKey)
public LogChannel Get(string? apiKey)
{
return new LogBuffer(async (c) => await Task.Delay(TimeSpan.FromSeconds(1), c), default);
return new LogChannel(async (c) => await Task.Delay(TimeSpan.FromSeconds(1), c), default);
}

public Task StopAsync()
Expand Down
29 changes: 29 additions & 0 deletions src/SeqCli/Forwarder/Filesystem/EmptyStoreFileReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright © Datalust Pty Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;

namespace SeqCli.Forwarder.Filesystem;

sealed class EmptyStoreFileReader : StoreFileReader
{
public override void Dispose()
{
}

public override long CopyTo(Span<byte> buffer, long from = 0, long? length = null)
{
return 0;
}
}
91 changes: 91 additions & 0 deletions src/SeqCli/Forwarder/Filesystem/StoreDirectory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright © Datalust Pty Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

namespace SeqCli.Forwarder.Filesystem;

/// <summary>
/// A container of <see cref="StoreFile" />s and their names.
/// </summary>
abstract class StoreDirectory
{
/// <summary>
/// Create a new file with the given name, linking it into the filesystem.
/// </summary>
public abstract StoreFile Create(string name);

public virtual (string, StoreFile) CreateTemporary()
{
var tmpName = $"rc{Guid.NewGuid():N}.tmp";
return (tmpName, Create(tmpName));
}

/// <summary>
/// Delete a file with the given name, returning whether the file was deleted.
/// </summary>
public abstract bool TryDelete(string name);

/// <summary>
/// Atomically replace the contents of one file with another, creating it if it doesn't exist and deleting the other.
/// </summary>
public abstract StoreFile Replace(string toReplace, string replaceWith);

/// <summary>
/// Atomically replace the contents of a file.
/// </summary>
public virtual StoreFile ReplaceContents(string name, Span<byte> contents, bool sync = true)
{
var (tmpName, tmpFile) = CreateTemporary();

try
{
if (!tmpFile.TryOpenAppend(out var opened))
throw new Exception("Failed to write to a temporary file that was just created.");

using var writer = opened;
writer.Append(contents);
writer.Commit();

if (sync) writer.Sync();
}
catch
{
TryDelete(tmpName);
throw;
}

return Replace(name, tmpName);
}

/// <summary>
/// List all files in unspecified order.
/// </summary>
public abstract IEnumerable<(string Name, StoreFile File)> List(Func<string, bool> predicate);

/// <summary>
/// Try get a file by name.
/// </summary>
public virtual bool TryGet(string name, [NotNullWhen(true)] out StoreFile? file)
{
file = List(n => n == name)
.Select(p => p.File)
.FirstOrDefault();

return file != null;
}
}
Loading