Skip to content

Conversation

@Insomniak47
Copy link
Member

@Insomniak47 Insomniak47 commented Sep 16, 2023

Just an initial experimenting branch I've had around for a bit where I'm trying to see how I wanna structure the Daemon stuff.

I've got separate projects for the Windows and linux daemons because I wanted to test if it would cause any differences with trimming etc. It doesn't seem to have any impact so I'll be merging them together again and probably going to nuke the Server project entirely.

Other than that I'm basically thinking of just using named pipes on windows and UDS on linux/mac to do IPC and then just polling in the background as we do now to populate a teeny SQLite server that we update. I figure it'd be kinda neat to do it with change streaming and tracking certain things though it's kinda hard because the GH api makes so few promises to you about the actual correctness of your data (looking at you status flags)

In order to do a bunch of this I had to bump to net 8 and preview versions (for named pipe support in kestrel). Also I added some really horrendous annotations on the generics to make them compatible with the trimming stuff but god I hope there's a better way to do it going forward. Those required C#11 to work properly.

edit: Oh also I was experimenting with the CodeGenerator configuration stuff but it wasn't working for me so I have it gated behind the Release-Preview build which I don't think I actually added atm.

edit2: I also added a little commandline util called 'Geas' to handle experimenting with it before implementing it in Peer

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You like this?

<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would be worth using configurations more liberally so dockerfiles, workflows, etc. could just pass configurations and the meanings could be contained in a propertygroup like this.

Comment on lines +4 to +28
namespace Peer.Daemon.Linux
{
internal class Program
{
private const string _socketPath = "/var/run/peerless/peerless.sock";
static async Task Main()
{
Directory.CreateDirectory(Directory.GetParent(_socketPath)!.FullName);
File.Delete(_socketPath);

var app = ServerBuilder.CreateHost(cfg =>
{
cfg.WebHost.UseKestrel(kestrel =>
{
kestrel.ListenUnixSocket(_socketPath, opts =>
{
opts.Protocols = HttpProtocols.Http2;
});
});
});

await app.RunAsync();
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
namespace Peer.Daemon.Linux
{
internal class Program
{
private const string _socketPath = "/var/run/peerless/peerless.sock";
static async Task Main()
{
Directory.CreateDirectory(Directory.GetParent(_socketPath)!.FullName);
File.Delete(_socketPath);
var app = ServerBuilder.CreateHost(cfg =>
{
cfg.WebHost.UseKestrel(kestrel =>
{
kestrel.ListenUnixSocket(_socketPath, opts =>
{
opts.Protocols = HttpProtocols.Http2;
});
});
});
await app.RunAsync();
}
}
}
namespace Peer.Daemon.Linux;
internal class Program
{
private const string _socketPath = "/var/run/peerless/peerless.sock";
static async Task Main()
{
Directory.CreateDirectory(Directory.GetParent(_socketPath)!.FullName);
File.Delete(_socketPath);
var app = ServerBuilder.CreateHost(cfg =>
{
cfg.WebHost.UseKestrel(kestrel =>
{
kestrel.ListenUnixSocket(_socketPath, opts =>
{
opts.Protocols = HttpProtocols.Http2;
});
});
});
await app.RunAsync();
}
}

static async Task Main()
{
Directory.CreateDirectory(Directory.GetParent(_socketPath)!.FullName);
File.Delete(_socketPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this blow up an already running instance if a second one were started? I wonder if it would better to be aggressive about cleanup and fail to start if the socket is already open? I bet there's prior art about this somewhere.

using Grpc.Net.Client;
using Peerless;

namespace Geas;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nerd

// package peerless;

service PullRequestGrpcService {
rpc GetPullRequest(GetPullRequestRequest) returns (GetPullRequestResponse);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RequestRequest 🤮 I get it though.

message State {
PRStatus status = 1;
int32 total_comments = 2;
int32 active_comments =3;
Copy link
Member

@ttd2089 ttd2089 Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int32 active_comments =3;
int32 active_comments =3;

Comment on lines +31 to +32
var src = host.Services.GetRequiredService<EndpointDataSource>();
return host;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src unused?

}

//Linux
public partial class SpecialPaths
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't compile conditionally, wouldn't these paths end up being used on Windows too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants