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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ dotnet tool install --global seqcli
To set a default server URL and API key, run:

```
seqcli config -k connection.serverUrl -v https://your-seq-server
seqcli config -k connection.apiKey -v your-api-key
seqcli config set -k connection.serverUrl -v https://your-seq-server
seqcli config set -k connection.apiKey -v your-api-key
```

The API key will be stored in your `SeqCli.json` configuration file; on Windows, this is encrypted using DPAPI; on Mac/Linux the key is stored in plain text unless an encryptor is defined in `encryption.encryptor`. As an alternative to storing the API key in configuration, it can be passed to each command via the `--apikey=` argument.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace SeqCli.Config.Forwarder;

public class SeqCliForwarderStorageConfig
{
public long TargetChunkSizeBytes { get; set; } = 10 * 512 * 1024;
public long TargetChunkSizeBytes { get; set; } = 100 * 512 * 1024;
public int? MaxChunks { get; set; } = null;
}
3 changes: 2 additions & 1 deletion src/SeqCli/Encryptor/ExternalDataProtector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Diagnostics;
using System.Text;
using System.Threading;
using SeqCli.Config;

namespace SeqCli.Encryptor;

Expand Down Expand Up @@ -110,6 +109,8 @@ static int Invoke(string fullExePath, string? args, byte[] stdin, out byte[] std

stdout = stdoutBuf.AsSpan()[..stdoutBufLength].ToArray();
ArrayPool<byte>.Shared.Return(stdoutBuf);

process.WaitForExit(TimeSpan.FromSeconds(30));

return process.ExitCode;
}
Expand Down
90 changes: 0 additions & 90 deletions src/SeqCli/Forwarder/Channel/ApiKeyForwardingChannelWrapper.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// 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.IO;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -9,13 +24,12 @@

namespace SeqCli.Forwarder.Channel;

internal abstract class ForwardingChannelWrapper(string bufferPath, SeqConnection connection, SeqCliConfig config)
abstract class ForwardingAuthenticationStrategy(string bufferPath, SeqConnection connection, SeqCliConfig config)
{
protected const string SeqCliConnectionChannelId = "SeqCliConnection";
readonly CancellationTokenSource _shutdownTokenSource = new();

protected readonly string BufferPath = bufferPath;
protected readonly SeqCliConfig Config = config;
protected readonly CancellationTokenSource ShutdownTokenSource = new();
protected readonly Lock ChannelsSync = new();

// <param name="id">The id used for the channel storage on the file system.</param>
// <param name="apiKey">The apiKey that will be used to connect to the downstream Seq instance.</param>
Expand All @@ -24,7 +38,7 @@ protected ForwardingChannel OpenOrCreateChannel(string id, string? apiKey)
var storePath = GetStorePath(id);
var store = new SystemStoreDirectory(storePath);

Log.ForContext<ForwardingChannelWrapper>().Information("Opening local buffer in {StorePath}", storePath);
Log.ForContext<ForwardingAuthenticationStrategy>().Information("Opening local buffer in {StorePath}", storePath);

return new ForwardingChannel(
BufferAppender.Open(store),
Expand All @@ -35,15 +49,25 @@ protected ForwardingChannel OpenOrCreateChannel(string id, string? apiKey)
Config.Forwarder.Storage.TargetChunkSizeBytes,
Config.Forwarder.Storage.MaxChunks,
Config.Connection.BatchSizeLimitBytes,
ShutdownTokenSource.Token);
_shutdownTokenSource.Token);
}

public abstract ForwardingChannel GetForwardingChannel(string? requestApiKey);

public abstract Task StopAsync();

protected async Task OnStoppedAsync()
{
await _shutdownTokenSource.CancelAsync();
}

protected void OnStopping()
{
_shutdownTokenSource.CancelAfter(TimeSpan.FromSeconds(30));
}

protected string GetStorePath(string id)
{
return Path.Combine(BufferPath, id);
}
}
}
14 changes: 14 additions & 0 deletions src/SeqCli/Forwarder/Channel/ForwardingChannel.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// 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.IO;
using System.Threading;
Expand Down
14 changes: 14 additions & 0 deletions src/SeqCli/Forwarder/Channel/ForwardingChannelEntry.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// 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.Threading.Tasks;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// 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.Threading.Tasks;
using Seq.Api;
using SeqCli.Config;
using Serilog;

namespace SeqCli.Forwarder.Channel;

class SharedConnectionForwardingAuthenticationStrategy: ForwardingAuthenticationStrategy
{
public const string ChannelId = "SharedConnection";

readonly ForwardingChannel _sharedForwardingChannel;

public SharedConnectionForwardingAuthenticationStrategy(string bufferPath, SeqConnection connection, SeqCliConfig config, string? seqCliApiKey): base(bufferPath, connection, config)
{
_sharedForwardingChannel = OpenOrCreateChannel(ChannelId, seqCliApiKey);
}

public override ForwardingChannel GetForwardingChannel(string? _)
{
return _sharedForwardingChannel;
}

public override async Task StopAsync()
{
Log.ForContext<SharedConnectionForwardingAuthenticationStrategy>().Information("Flushing log buffer");
OnStopping();

await _sharedForwardingChannel.StopAsync();
await OnStoppedAsync();
}
}
Loading