From 00ab0323c754c1e106ef31eb6eaa7100fee806ad Mon Sep 17 00:00:00 2001 From: Brandon Watson Date: Thu, 4 Mar 2021 01:57:21 -0500 Subject: [PATCH] Initial Commit --- .gitignore | 37 ++++++++++ Src/Program.cs | 27 +++++++ Src/Protos/signal.proto | 130 ++++++++++++++++++++++++++++++++++ Src/Services/SignalService.cs | 19 +++++ Src/Startup.cs | 43 +++++++++++ appsettings.Development.json | 10 +++ appsettings.json | 15 ++++ aurora-cradle-sharp.csproj | 15 ++++ workspace.code-workspace | 12 ++++ 9 files changed, 308 insertions(+) create mode 100644 .gitignore create mode 100644 Src/Program.cs create mode 100644 Src/Protos/signal.proto create mode 100644 Src/Services/SignalService.cs create mode 100644 Src/Startup.cs create mode 100644 appsettings.Development.json create mode 100644 appsettings.json create mode 100644 aurora-cradle-sharp.csproj create mode 100644 workspace.code-workspace diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0626272 --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +*.swp +*.*~ +project.lock.json +.DS_Store +*.pyc +nupkg/ + +# Visual Studio Code +.vscode + +# Rider +.idea + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +msbuild.log +msbuild.err +msbuild.wrn + +# Visual Studio 2015 +.vs/ \ No newline at end of file diff --git a/Src/Program.cs b/Src/Program.cs new file mode 100644 index 0000000..e35ec24 --- /dev/null +++ b/Src/Program.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace aurora_cradle_sharp +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + // Additional configuration is required to successfully run gRPC on macOS. + // For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682 + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} diff --git a/Src/Protos/signal.proto b/Src/Protos/signal.proto new file mode 100644 index 0000000..8ba2d23 --- /dev/null +++ b/Src/Protos/signal.proto @@ -0,0 +1,130 @@ +syntax = "proto3"; + +option csharp_namespace = "aurora_cradle_sharp"; + +package signal; + + +import "google/protobuf/timestamp.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/empty.proto"; + +service Signal{ + //************** + //Party Resource + //************** + //Get Party + rpc ListParties(ListPartiesRequest) returns (ListPartiesResponse); + rpc GetParty(GetPartyRequest) returns (Party); + rpc UpdateParty(UpdatePartyRequest) returns (Party); + rpc CreateParty(CreatePartyRequest) returns (Party); + rpc DeleteParty(DeletePartyRequest) returns (google.protobuf.Empty); + //*************************** + //EventSubscriptions Resource + //*************************** + //List + rpc ListEventSubscriptions(ListEventSubscriptionsRequest) returns (ListEventSubscriptionsResponse); + //Create + rpc SubscribeToEvent(EventSubscriptionRequest) returns (EventSubscription); + + //Delete + rpc DeleteEventSubscription(DeleteEventSubscriptionRequest) returns (google.protobuf.Empty); + //CUSTOM: Create EventSubscription List + rpc SubscribeToEvents(EventSubscriptionListRequest) returns (EventSubscriptionListResponse); + //CUSTOM: Delete all + rpc DeleteAllEventSubscriptions(DeleteAllEventSubscriptionsRequest) returns (google.protobuf.Empty); + + //***** + //Event + //***** + //Get + rpc GetEventStream(GetEventsRequest) returns (stream BaseEvent) {}; +} +message Party { + //The resource name of the party + string name = 1; + string party_id = 2; + string display_name = 3; + string description = 4; + string host_ip = 5; + google.protobuf.Timestamp created_on = 6; +} +message PartyListItem { + string name = 1; + string party_id = 2; +} +message ListPartiesRequest { + int32 page_size = 1; + string page_token = 2; +} +message ListPartiesResponse { + repeated PartyListItem parties = 1; + string next_page_token = 2; +} +message GetPartyRequest { + string party_id = 1; +} +message CreatePartyRequest { + string party_id = 1; + Party party = 2; +} +message DeletePartyRequest { + string party_id = 1; +} +message UpdatePartyRequest { + Party party = 1; + google.protobuf.FieldMask update_mask = 2; +} +/* Event Types */ +enum EventType { + NewPartiesAvailable = 0; +} +message NewPartiesAvailableEvent { +} +message BaseEvent { + //Resource name of the event ? + string name = 1; + EventType event_type = 2; + oneof derivedEvent { + NewPartiesAvailableEvent new_parties_available_event = 3; + } +} +message EventSubscription { + EventType type = 2; +} +message ListEventSubscriptionsRequest { + //Resource name of parent to the subscription list (The member) + string parent = 1; + int32 page_size = 2; + string page_token = 3; +} +message ListEventSubscriptionsResponse { + repeated EventSubscription subscriptions = 1; + string next_page_token = 2; +} +message EventSubscriptionRequest { + //Resource name of the parent to the subscription list (The member) + string parent = 1; + EventSubscription event_subscription = 2; +} +message DeleteEventSubscriptionRequest { + //Resource name of the subscription to delete + string parent = 1; + EventType type = 2; +} +message EventSubscriptionListRequest { + //Resource name of the parent to the subscription list (The member) + string parent = 1; + repeated EventSubscription event_subscriptions = 2; +} +message EventSubscriptionListResponse { + repeated EventSubscription event_subscriptions = 1; +} +message DeleteAllEventSubscriptionsRequest { + //Resource name of the parent to the subscription list (the member) + string parent = 1; +} +message GetEventsRequest { + //Resource name of the parent to the event stream (the member) + string parent = 1; +} \ No newline at end of file diff --git a/Src/Services/SignalService.cs b/Src/Services/SignalService.cs new file mode 100644 index 0000000..c7cab5f --- /dev/null +++ b/Src/Services/SignalService.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Grpc.Core; +using Microsoft.Extensions.Logging; + +namespace aurora_cradle_sharp +{ + public class SignalService : Signal.SignalBase + { + private readonly ILogger _logger; + public SignalService(ILogger logger) + { + _logger = logger; + } + + } +} diff --git a/Src/Startup.cs b/Src/Startup.cs new file mode 100644 index 0000000..5607904 --- /dev/null +++ b/Src/Startup.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace aurora_cradle_sharp +{ + public class Startup + { + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 + public void ConfigureServices(IServiceCollection services) + { + services.AddGrpc(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseRouting(); + + app.UseEndpoints(endpoints => + { + endpoints.MapGrpcService(); + + endpoints.MapGet("/", async context => + { + await context.Response.WriteAsync("Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909"); + }); + }); + } + } +} diff --git a/appsettings.Development.json b/appsettings.Development.json new file mode 100644 index 0000000..fe20c40 --- /dev/null +++ b/appsettings.Development.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Grpc": "Information", + "Microsoft": "Information" + } + } +} diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..df549a7 --- /dev/null +++ b/appsettings.json @@ -0,0 +1,15 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*", + "Kestrel": { + "EndpointDefaults": { + "Protocols": "Http1" + } + } +} diff --git a/aurora-cradle-sharp.csproj b/aurora-cradle-sharp.csproj new file mode 100644 index 0000000..2b41fe9 --- /dev/null +++ b/aurora-cradle-sharp.csproj @@ -0,0 +1,15 @@ + + + + netcoreapp3.1 + + + + + + + + + + + diff --git a/workspace.code-workspace b/workspace.code-workspace new file mode 100644 index 0000000..a0878cd --- /dev/null +++ b/workspace.code-workspace @@ -0,0 +1,12 @@ +{ + "folders": [ + { + "path": "." + } + ], +"settings": { + "files.exclude": { + "**/obj": true + } +} +}