From 7637a9ffea1ae4c8a9e75784769bca5867f5448e Mon Sep 17 00:00:00 2001
From: Moritz Lang <16192401+slashmo@users.noreply.github.com>
Date: Thu, 4 Sep 2025 22:53:41 +0200
Subject: [PATCH 1/6] Delete C# cart service implementation
---
src/cart/Directory.Build.props | 11 -
src/cart/NuGet.config | 8 -
src/cart/cart.sln | 48 -----
src/cart/src/.dockerignore | 6 -
src/cart/src/Dockerfile | 41 ----
src/cart/src/Program.cs | 99 ---------
src/cart/src/appsettings.json | 15 --
src/cart/src/cart.csproj | 41 ----
src/cart/src/cartstore/ICartStore.cs | 17 --
src/cart/src/cartstore/ValkeyCartStore.cs | 238 ----------------------
src/cart/src/services/CartService.cs | 101 ---------
src/cart/tests/CartServiceTests.cs | 146 -------------
src/cart/tests/cart.tests.csproj | 21 --
13 files changed, 792 deletions(-)
delete mode 100644 src/cart/Directory.Build.props
delete mode 100644 src/cart/NuGet.config
delete mode 100644 src/cart/cart.sln
delete mode 100644 src/cart/src/.dockerignore
delete mode 100644 src/cart/src/Dockerfile
delete mode 100644 src/cart/src/Program.cs
delete mode 100644 src/cart/src/appsettings.json
delete mode 100644 src/cart/src/cart.csproj
delete mode 100644 src/cart/src/cartstore/ICartStore.cs
delete mode 100644 src/cart/src/cartstore/ValkeyCartStore.cs
delete mode 100644 src/cart/src/services/CartService.cs
delete mode 100644 src/cart/tests/CartServiceTests.cs
delete mode 100644 src/cart/tests/cart.tests.csproj
diff --git a/src/cart/Directory.Build.props b/src/cart/Directory.Build.props
deleted file mode 100644
index bfd1cab4dd..0000000000
--- a/src/cart/Directory.Build.props
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
- true
- all
- low
-
-
-
- true
-
-
diff --git a/src/cart/NuGet.config b/src/cart/NuGet.config
deleted file mode 100644
index adcb2a925f..0000000000
--- a/src/cart/NuGet.config
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/src/cart/cart.sln b/src/cart/cart.sln
deleted file mode 100644
index 6fedf6359f..0000000000
--- a/src/cart/cart.sln
+++ /dev/null
@@ -1,48 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26124.0
-MinimumVisualStudioVersion = 15.0.26124.0
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cart", "src\cart.csproj", "{2348C29F-E8D3-4955-916D-D609CBC97FCB}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cart.tests", "tests\cart.tests.csproj", "{59825342-CE64-4AFA-8744-781692C0811B}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|Any CPU = Release|Any CPU
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {2348C29F-E8D3-4955-916D-D609CBC97FCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2348C29F-E8D3-4955-916D-D609CBC97FCB}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2348C29F-E8D3-4955-916D-D609CBC97FCB}.Debug|x64.ActiveCfg = Debug|Any CPU
- {2348C29F-E8D3-4955-916D-D609CBC97FCB}.Debug|x64.Build.0 = Debug|Any CPU
- {2348C29F-E8D3-4955-916D-D609CBC97FCB}.Debug|x86.ActiveCfg = Debug|Any CPU
- {2348C29F-E8D3-4955-916D-D609CBC97FCB}.Debug|x86.Build.0 = Debug|Any CPU
- {2348C29F-E8D3-4955-916D-D609CBC97FCB}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2348C29F-E8D3-4955-916D-D609CBC97FCB}.Release|Any CPU.Build.0 = Release|Any CPU
- {2348C29F-E8D3-4955-916D-D609CBC97FCB}.Release|x64.ActiveCfg = Release|Any CPU
- {2348C29F-E8D3-4955-916D-D609CBC97FCB}.Release|x64.Build.0 = Release|Any CPU
- {2348C29F-E8D3-4955-916D-D609CBC97FCB}.Release|x86.ActiveCfg = Release|Any CPU
- {2348C29F-E8D3-4955-916D-D609CBC97FCB}.Release|x86.Build.0 = Release|Any CPU
- {59825342-CE64-4AFA-8744-781692C0811B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {59825342-CE64-4AFA-8744-781692C0811B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {59825342-CE64-4AFA-8744-781692C0811B}.Debug|x64.ActiveCfg = Debug|Any CPU
- {59825342-CE64-4AFA-8744-781692C0811B}.Debug|x64.Build.0 = Debug|Any CPU
- {59825342-CE64-4AFA-8744-781692C0811B}.Debug|x86.ActiveCfg = Debug|Any CPU
- {59825342-CE64-4AFA-8744-781692C0811B}.Debug|x86.Build.0 = Debug|Any CPU
- {59825342-CE64-4AFA-8744-781692C0811B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {59825342-CE64-4AFA-8744-781692C0811B}.Release|Any CPU.Build.0 = Release|Any CPU
- {59825342-CE64-4AFA-8744-781692C0811B}.Release|x64.ActiveCfg = Release|Any CPU
- {59825342-CE64-4AFA-8744-781692C0811B}.Release|x64.Build.0 = Release|Any CPU
- {59825342-CE64-4AFA-8744-781692C0811B}.Release|x86.ActiveCfg = Release|Any CPU
- {59825342-CE64-4AFA-8744-781692C0811B}.Release|x86.Build.0 = Release|Any CPU
- EndGlobalSection
-EndGlobal
diff --git a/src/cart/src/.dockerignore b/src/cart/src/.dockerignore
deleted file mode 100644
index 0224086eb2..0000000000
--- a/src/cart/src/.dockerignore
+++ /dev/null
@@ -1,6 +0,0 @@
-**/*.sh
-**/*.bat
-**/bin/
-**/obj/
-**/out/
-Dockerfile*
\ No newline at end of file
diff --git a/src/cart/src/Dockerfile b/src/cart/src/Dockerfile
deleted file mode 100644
index 9e4df98450..0000000000
--- a/src/cart/src/Dockerfile
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright The OpenTelemetry Authors
-# SPDX-License-Identifier: Apache-2.0
-# Copyright 2021 Google LLC
-#
-# 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.
-
-# https://mcr.microsoft.com/v2/dotnet/sdk/tags/list
-FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS builder
-ARG TARGETARCH
-
-WORKDIR /usr/src/app/
-
-COPY ./src/cart/ ./
-COPY ./pb/ ./pb/
-
-RUN dotnet restore ./src/cart.csproj -r linux-musl-$TARGETARCH
-
-RUN dotnet publish ./src/cart.csproj -r linux-musl-$TARGETARCH --no-restore -o /cart
-
-# -----------------------------------------------------------------------------
-
-# https://mcr.microsoft.com/v2/dotnet/runtime-deps/tags/list
-FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine3.20
-
-WORKDIR /usr/src/app/
-COPY --from=builder /cart/ ./
-
-ENV DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE=false
-
-EXPOSE ${CART_PORT}
-ENTRYPOINT [ "./cart" ]
diff --git a/src/cart/src/Program.cs b/src/cart/src/Program.cs
deleted file mode 100644
index 588bcb28f5..0000000000
--- a/src/cart/src/Program.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright The OpenTelemetry Authors
-// SPDX-License-Identifier: Apache-2.0
-using System;
-
-using cart.cartstore;
-using cart.services;
-
-using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Http;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Diagnostics.HealthChecks;
-using Microsoft.Extensions.Logging;
-using OpenTelemetry.Instrumentation.StackExchangeRedis;
-using OpenTelemetry.Logs;
-using OpenTelemetry.Metrics;
-using OpenTelemetry.Resources;
-using OpenTelemetry.Trace;
-using OpenFeature;
-using OpenFeature.Contrib.Providers.Flagd;
-using OpenFeature.Hooks;
-
-var builder = WebApplication.CreateBuilder(args);
-string valkeyAddress = builder.Configuration["VALKEY_ADDR"];
-if (string.IsNullOrEmpty(valkeyAddress))
-{
- Console.WriteLine("VALKEY_ADDR environment variable is required.");
- Environment.Exit(1);
-}
-
-builder.Logging
- .AddOpenTelemetry(options => options.AddOtlpExporter())
- .AddConsole();
-
-builder.Services.AddSingleton(x =>
-{
- var store = new ValkeyCartStore(x.GetRequiredService>(), valkeyAddress);
- store.Initialize();
- return store;
-});
-
-builder.Services.AddOpenFeature(openFeatureBuilder =>
-{
- openFeatureBuilder
- .AddHostedFeatureLifecycle()
- .AddProvider(_ => new FlagdProvider())
- .AddHook()
- .AddHook();
-});
-
-builder.Services.AddSingleton(x =>
- new CartService(
- x.GetRequiredService(),
- new ValkeyCartStore(x.GetRequiredService>(), "badhost:1234"),
- x.GetRequiredService()
-));
-
-
-Action appResourceBuilder =
- resource => resource
- .AddService(builder.Environment.ApplicationName)
- .AddContainerDetector()
- .AddHostDetector();
-
-builder.Services.AddOpenTelemetry()
- .ConfigureResource(appResourceBuilder)
- .WithTracing(tracerBuilder => tracerBuilder
- .AddSource("OpenTelemetry.Demo.Cart")
- .AddRedisInstrumentation(
- options => options.SetVerboseDatabaseStatements = true)
- .AddAspNetCoreInstrumentation()
- .AddGrpcClientInstrumentation()
- .AddHttpClientInstrumentation()
- .AddOtlpExporter())
- .WithMetrics(meterBuilder => meterBuilder
- .AddMeter("OpenTelemetry.Demo.Cart")
- .AddMeter("OpenFeature")
- .AddProcessInstrumentation()
- .AddRuntimeInstrumentation()
- .AddAspNetCoreInstrumentation()
- .SetExemplarFilter(ExemplarFilterType.TraceBased)
- .AddOtlpExporter());
-builder.Services.AddGrpc();
-builder.Services.AddGrpcHealthChecks()
- .AddCheck("Sample", () => HealthCheckResult.Healthy());
-
-var app = builder.Build();
-
-var ValkeyCartStore = (ValkeyCartStore)app.Services.GetRequiredService();
-app.Services.GetRequiredService().AddConnection(ValkeyCartStore.GetConnection());
-
-app.MapGrpcService();
-app.MapGrpcHealthChecksService();
-
-app.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");
-});
-
-app.Run();
diff --git a/src/cart/src/appsettings.json b/src/cart/src/appsettings.json
deleted file mode 100644
index db76fce393..0000000000
--- a/src/cart/src/appsettings.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information"
- }
- },
- "AllowedHosts": "*",
- "Kestrel": {
- "EndpointDefaults": {
- "Protocols": "Http2"
- }
- }
-}
\ No newline at end of file
diff --git a/src/cart/src/cart.csproj b/src/cart/src/cart.csproj
deleted file mode 100644
index 4092cc1f05..0000000000
--- a/src/cart/src/cart.csproj
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
- net8.0
- false
- false
- true
- true
- false
- $(ProjectDir)..\pb
-
-
-
- ..\..\..\pb
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/cart/src/cartstore/ICartStore.cs b/src/cart/src/cartstore/ICartStore.cs
deleted file mode 100644
index 80e249e5d6..0000000000
--- a/src/cart/src/cartstore/ICartStore.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright The OpenTelemetry Authors
-// SPDX-License-Identifier: Apache-2.0
-using System.Threading.Tasks;
-
-namespace cart.cartstore;
-
-public interface ICartStore
-{
- void Initialize();
-
- Task AddItemAsync(string userId, string productId, int quantity);
- Task EmptyCartAsync(string userId);
-
- Task GetCartAsync(string userId);
-
- bool Ping();
-}
diff --git a/src/cart/src/cartstore/ValkeyCartStore.cs b/src/cart/src/cartstore/ValkeyCartStore.cs
deleted file mode 100644
index 8b230baaa4..0000000000
--- a/src/cart/src/cartstore/ValkeyCartStore.cs
+++ /dev/null
@@ -1,238 +0,0 @@
-// Copyright The OpenTelemetry Authors
-// SPDX-License-Identifier: Apache-2.0
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-using Grpc.Core;
-using StackExchange.Redis;
-using Google.Protobuf;
-using Microsoft.Extensions.Logging;
-using System.Diagnostics.Metrics;
-using System.Diagnostics;
-
-namespace cart.cartstore;
-
-public class ValkeyCartStore : ICartStore
-{
- private readonly ILogger _logger;
- private const string CartFieldName = "cart";
- private const int RedisRetryNumber = 30;
-
- private volatile ConnectionMultiplexer _redis;
- private volatile bool _isRedisConnectionOpened;
-
- private readonly object _locker = new();
- private readonly byte[] _emptyCartBytes;
- private readonly string _connectionString;
-
- private static readonly ActivitySource CartActivitySource = new("OpenTelemetry.Demo.Cart");
- private static readonly Meter CartMeter = new Meter("OpenTelemetry.Demo.Cart");
- private static readonly Histogram addItemHistogram = CartMeter.CreateHistogram(
- "app.cart.add_item.latency",
- unit: "s",
- advice: new InstrumentAdvice
- {
- HistogramBucketBoundaries = [ 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 ]
- });
- private static readonly Histogram getCartHistogram = CartMeter.CreateHistogram(
- "app.cart.get_cart.latency",
- unit: "s",
- advice: new InstrumentAdvice
- {
- HistogramBucketBoundaries = [ 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 ]
- });
- private readonly ConfigurationOptions _redisConnectionOptions;
-
- public ValkeyCartStore(ILogger logger, string valkeyAddress)
- {
- _logger = logger;
- // Serialize empty cart into byte array.
- var cart = new Oteldemo.Cart();
- _emptyCartBytes = cart.ToByteArray();
- _connectionString = $"{valkeyAddress},ssl=false,allowAdmin=true,abortConnect=false";
-
- _redisConnectionOptions = ConfigurationOptions.Parse(_connectionString);
-
- // Try to reconnect multiple times if the first retry fails.
- _redisConnectionOptions.ConnectRetry = RedisRetryNumber;
- _redisConnectionOptions.ReconnectRetryPolicy = new ExponentialRetry(1000);
-
- _redisConnectionOptions.KeepAlive = 180;
- }
-
- public ConnectionMultiplexer GetConnection()
- {
- EnsureRedisConnected();
- return _redis;
- }
-
- public void Initialize()
- {
- EnsureRedisConnected();
- }
-
- private void EnsureRedisConnected()
- {
- if (_isRedisConnectionOpened)
- {
- return;
- }
-
- // Connection is closed or failed - open a new one but only at the first thread
- lock (_locker)
- {
- if (_isRedisConnectionOpened)
- {
- return;
- }
-
- _logger.LogDebug("Connecting to Redis: {_connectionString}", _connectionString);
- _redis = ConnectionMultiplexer.Connect(_redisConnectionOptions);
-
- if (_redis == null || !_redis.IsConnected)
- {
- _logger.LogError("Wasn't able to connect to redis");
-
- // We weren't able to connect to Redis despite some retries with exponential backoff.
- throw new ApplicationException("Wasn't able to connect to redis");
- }
-
- _logger.LogInformation("Successfully connected to Redis");
- var cache = _redis.GetDatabase();
-
- _logger.LogDebug("Performing small test");
- cache.StringSet("cart", "OK" );
- object res = cache.StringGet("cart");
- _logger.LogDebug("Small test result: {res}", res);
-
- _redis.InternalError += (_, e) => { Console.WriteLine(e.Exception); };
- _redis.ConnectionRestored += (_, _) =>
- {
- _isRedisConnectionOpened = true;
- _logger.LogInformation("Connection to redis was restored successfully.");
- };
- _redis.ConnectionFailed += (_, _) =>
- {
- _logger.LogInformation("Connection failed. Disposing the object");
- _isRedisConnectionOpened = false;
- };
-
- _isRedisConnectionOpened = true;
- }
- }
-
- public async Task AddItemAsync(string userId, string productId, int quantity)
- {
- var stopwatch = Stopwatch.StartNew();
- _logger.LogInformation($"AddItemAsync called with userId={userId}, productId={productId}, quantity={quantity}");
-
- try
- {
- EnsureRedisConnected();
-
- var db = _redis.GetDatabase();
-
- // Access the cart from the cache
- var value = await db.HashGetAsync(userId, CartFieldName);
-
- Oteldemo.Cart cart;
- if (value.IsNull)
- {
- cart = new Oteldemo.Cart
- {
- UserId = userId
- };
- cart.Items.Add(new Oteldemo.CartItem { ProductId = productId, Quantity = quantity });
- }
- else
- {
- cart = Oteldemo.Cart.Parser.ParseFrom(value);
- var existingItem = cart.Items.SingleOrDefault(i => i.ProductId == productId);
- if (existingItem == null)
- {
- cart.Items.Add(new Oteldemo.CartItem { ProductId = productId, Quantity = quantity });
- }
- else
- {
- existingItem.Quantity += quantity;
- }
- }
-
- await db.HashSetAsync(userId, new[]{ new HashEntry(CartFieldName, cart.ToByteArray()) });
- await db.KeyExpireAsync(userId, TimeSpan.FromMinutes(60));
- }
- catch (Exception ex)
- {
- throw new RpcException(new Status(StatusCode.FailedPrecondition, $"Can't access cart storage. {ex}"));
- }
- finally
- {
- addItemHistogram.Record(stopwatch.Elapsed.TotalSeconds);
- }
- }
-
- public async Task EmptyCartAsync(string userId)
- {
- _logger.LogInformation($"EmptyCartAsync called with userId={userId}");
-
- try
- {
- EnsureRedisConnected();
- var db = _redis.GetDatabase();
-
- // Update the cache with empty cart for given user
- await db.HashSetAsync(userId, new[] { new HashEntry(CartFieldName, _emptyCartBytes) });
- await db.KeyExpireAsync(userId, TimeSpan.FromMinutes(60));
- }
- catch (Exception ex)
- {
- throw new RpcException(new Status(StatusCode.FailedPrecondition, $"Can't access cart storage. {ex}"));
- }
- }
-
- public async Task GetCartAsync(string userId)
- {
- var stopwatch = Stopwatch.StartNew();
- _logger.LogInformation($"GetCartAsync called with userId={userId}");
-
- try
- {
- EnsureRedisConnected();
-
- var db = _redis.GetDatabase();
-
- // Access the cart from the cache
- var value = await db.HashGetAsync(userId, CartFieldName);
-
- if (!value.IsNull)
- {
- return Oteldemo.Cart.Parser.ParseFrom(value);
- }
-
- // We decided to return empty cart in cases when user wasn't in the cache before
- return new Oteldemo.Cart();
- }
- catch (Exception ex)
- {
- throw new RpcException(new Status(StatusCode.FailedPrecondition, $"Can't access cart storage. {ex}"));
- }
- finally
- {
- getCartHistogram.Record(stopwatch.Elapsed.TotalSeconds);
- }
- }
-
- public bool Ping()
- {
- try
- {
- var cache = _redis.GetDatabase();
- var res = cache.Ping();
- return res != TimeSpan.Zero;
- }
- catch (Exception)
- {
- return false;
- }
- }
-}
diff --git a/src/cart/src/services/CartService.cs b/src/cart/src/services/CartService.cs
deleted file mode 100644
index 5578f45fff..0000000000
--- a/src/cart/src/services/CartService.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright The OpenTelemetry Authors
-// SPDX-License-Identifier: Apache-2.0
-using System.Diagnostics;
-using System.Threading.Tasks;
-using System;
-using Grpc.Core;
-using cart.cartstore;
-using OpenFeature;
-using Oteldemo;
-
-namespace cart.services;
-
-public class CartService : Oteldemo.CartService.CartServiceBase
-{
- private static readonly Empty Empty = new();
- private readonly Random random = new Random();
- private readonly ICartStore _badCartStore;
- private readonly ICartStore _cartStore;
- private readonly IFeatureClient _featureFlagHelper;
-
- public CartService(ICartStore cartStore, ICartStore badCartStore, IFeatureClient featureFlagService)
- {
- _badCartStore = badCartStore;
- _cartStore = cartStore;
- _featureFlagHelper = featureFlagService;
- }
-
- public override async Task AddItem(AddItemRequest request, ServerCallContext context)
- {
- var activity = Activity.Current;
- activity?.SetTag("app.user.id", request.UserId);
- activity?.SetTag("app.product.id", request.Item.ProductId);
- activity?.SetTag("app.product.quantity", request.Item.Quantity);
-
- try
- {
- await _cartStore.AddItemAsync(request.UserId, request.Item.ProductId, request.Item.Quantity);
-
- return Empty;
- }
- catch (RpcException ex)
- {
- activity?.AddException(ex);
- activity?.SetStatus(ActivityStatusCode.Error, ex.Message);
- throw;
- }
- }
-
- public override async Task GetCart(GetCartRequest request, ServerCallContext context)
- {
- var activity = Activity.Current;
- activity?.SetTag("app.user.id", request.UserId);
- activity?.AddEvent(new("Fetch cart"));
-
- try
- {
- var cart = await _cartStore.GetCartAsync(request.UserId);
- var totalCart = 0;
- foreach (var item in cart.Items)
- {
- totalCart += item.Quantity;
- }
- activity?.SetTag("app.cart.items.count", totalCart);
-
- return cart;
- }
- catch (RpcException ex)
- {
- activity?.AddException(ex);
- activity?.SetStatus(ActivityStatusCode.Error, ex.Message);
- throw;
- }
- }
-
- public override async Task EmptyCart(EmptyCartRequest request, ServerCallContext context)
- {
- var activity = Activity.Current;
- activity?.SetTag("app.user.id", request.UserId);
- activity?.AddEvent(new("Empty cart"));
-
- try
- {
- if (await _featureFlagHelper.GetBooleanValueAsync("cartFailure", false))
- {
- await _badCartStore.EmptyCartAsync(request.UserId);
- }
- else
- {
- await _cartStore.EmptyCartAsync(request.UserId);
- }
- }
- catch (RpcException ex)
- {
- Activity.Current?.AddException(ex);
- Activity.Current?.SetStatus(ActivityStatusCode.Error, ex.Message);
- throw;
- }
-
- return Empty;
- }
-}
diff --git a/src/cart/tests/CartServiceTests.cs b/src/cart/tests/CartServiceTests.cs
deleted file mode 100644
index 45173d1432..0000000000
--- a/src/cart/tests/CartServiceTests.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-// Copyright The OpenTelemetry Authors
-// SPDX-License-Identifier: Apache-2.0
-using System;
-using System.Threading.Tasks;
-using Grpc.Net.Client;
-using Oteldemo;
-using Microsoft.AspNetCore.TestHost;
-using Microsoft.Extensions.Hosting;
-using Xunit;
-using static Oteldemo.CartService;
-
-namespace cart.tests;
-
-public class CartServiceTests
-{
- private readonly IHostBuilder _host;
-
- public CartServiceTests()
- {
- _host = new HostBuilder().ConfigureWebHost(webBuilder =>
- {
- webBuilder
- // .UseStartup()
- .UseTestServer();
- });
- }
-
- [Fact(Skip = "See https://github.com/open-telemetry/opentelemetry-demo/pull/746#discussion_r1107931240")]
- public async Task GetItem_NoAddItemBefore_EmptyCartReturned()
- {
- // Setup test server and client
- using var server = await _host.StartAsync();
- var httpClient = server.GetTestClient();
-
- string userId = Guid.NewGuid().ToString();
-
- // Create a GRPC communication channel between the client and the server
- var channel = GrpcChannel.ForAddress(httpClient.BaseAddress, new GrpcChannelOptions
- {
- HttpClient = httpClient
- });
-
- var cartClient = new CartServiceClient(channel);
-
- var request = new GetCartRequest
- {
- UserId = userId,
- };
-
- var cart = await cartClient.GetCartAsync(request);
- Assert.NotNull(cart);
-
- // All grpc objects implement IEquitable, so we can compare equality with by-value semantics
- Assert.Equal(new Cart(), cart);
- }
-
- [Fact(Skip = "See https://github.com/open-telemetry/opentelemetry-demo/pull/746#discussion_r1107931240")]
- public async Task AddItem_ItemExists_Updated()
- {
- // Setup test server and client
- using var server = await _host.StartAsync();
- var httpClient = server.GetTestClient();
-
- string userId = Guid.NewGuid().ToString();
-
- // Create a GRPC communication channel between the client and the server
- var channel = GrpcChannel.ForAddress(httpClient.BaseAddress, new GrpcChannelOptions
- {
- HttpClient = httpClient
- });
-
- var client = new CartServiceClient(channel);
- var request = new AddItemRequest
- {
- UserId = userId,
- Item = new CartItem
- {
- ProductId = "1",
- Quantity = 1
- }
- };
-
- // First add - nothing should fail
- await client.AddItemAsync(request);
-
- // Second add of existing product - quantity should be updated
- await client.AddItemAsync(request);
-
- var getCartRequest = new GetCartRequest
- {
- UserId = userId
- };
- var cart = await client.GetCartAsync(getCartRequest);
- Assert.NotNull(cart);
- Assert.Equal(userId, cart.UserId);
- Assert.Single(cart.Items);
- Assert.Equal(2, cart.Items[0].Quantity);
-
- // Cleanup
- await client.EmptyCartAsync(new EmptyCartRequest { UserId = userId });
- }
-
- [Fact(Skip = "See https://github.com/open-telemetry/opentelemetry-demo/pull/746#discussion_r1107931240")]
- public async Task AddItem_New_Inserted()
- {
- // Setup test server and client
- using var server = await _host.StartAsync();
- var httpClient = server.GetTestClient();
-
- string userId = Guid.NewGuid().ToString();
-
- // Create a GRPC communication channel between the client and the server
- var channel = GrpcChannel.ForAddress(httpClient.BaseAddress, new GrpcChannelOptions
- {
- HttpClient = httpClient
- });
-
- // Create a proxy object to work with the server
- var client = new CartServiceClient(channel);
-
- var request = new AddItemRequest
- {
- UserId = userId,
- Item = new CartItem
- {
- ProductId = "1",
- Quantity = 1
- }
- };
-
- await client.AddItemAsync(request);
-
- var getCartRequest = new GetCartRequest
- {
- UserId = userId
- };
- var cart = await client.GetCartAsync(getCartRequest);
- Assert.NotNull(cart);
- Assert.Equal(userId, cart.UserId);
- Assert.Single(cart.Items);
-
- await client.EmptyCartAsync(new EmptyCartRequest { UserId = userId });
- cart = await client.GetCartAsync(getCartRequest);
- Assert.Empty(cart.Items);
- }
-}
diff --git a/src/cart/tests/cart.tests.csproj b/src/cart/tests/cart.tests.csproj
deleted file mode 100644
index 8c32df7aaa..0000000000
--- a/src/cart/tests/cart.tests.csproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
- net8.0
-
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
From c773c1e983af5f7ff79081e434c387fe2f15d7df Mon Sep 17 00:00:00 2001
From: Moritz Lang <16192401+slashmo@users.noreply.github.com>
Date: Thu, 4 Sep 2025 23:39:11 +0200
Subject: [PATCH 2/6] Create Swift cart service skeleton
---
.dockerignore | 4 +
.env | 2 +-
.gitignore | 2 +-
docker-compose.minimal.yml | 1 -
docker-compose.yml | 1 -
docker-gen-proto.sh | 16 +-
src/cart/.dockerignore | 3 +
src/cart/Dockerfile | 75 +
src/cart/Package.resolved | 240 ++
src/cart/Package.swift | 32 +
src/cart/README.md | 2 +-
src/cart/Sources/CTL/CartCTL.swift | 62 +
.../Sources/CTL/Generated/demo.grpc.swift | 2516 +++++++++++++++++
src/cart/Sources/CTL/Generated/demo.pb.swift | 2290 +++++++++++++++
src/cart/genproto/Dockerfile | 18 +
15 files changed, 5258 insertions(+), 6 deletions(-)
create mode 100644 src/cart/.dockerignore
create mode 100644 src/cart/Dockerfile
create mode 100644 src/cart/Package.resolved
create mode 100644 src/cart/Package.swift
create mode 100644 src/cart/Sources/CTL/CartCTL.swift
create mode 100644 src/cart/Sources/CTL/Generated/demo.grpc.swift
create mode 100644 src/cart/Sources/CTL/Generated/demo.pb.swift
create mode 100644 src/cart/genproto/Dockerfile
diff --git a/.dockerignore b/.dockerignore
index 94fdc73a30..5a21f3878f 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -22,3 +22,7 @@ src/*/*/Dockerfile
./src/shipping/target
###################################
+###################################
+# cart
+./src/cart/.build/
+###################################
diff --git a/.env b/.env
index c631f81a54..66b2770358 100644
--- a/.env
+++ b/.env
@@ -56,7 +56,7 @@ AD_DOCKERFILE=./src/ad/Dockerfile
# Cart Service
CART_PORT=7070
CART_ADDR=cart:${CART_PORT}
-CART_DOCKERFILE=./src/cart/src/Dockerfile
+CART_DOCKERFILE=./src/cart/Dockerfile
# Checkout Service
CHECKOUT_PORT=5050
diff --git a/.gitignore b/.gitignore
index 4dacf35195..ad967aec30 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ obj/
.gradle/
.idea/
build/
+.build/
node_modules/
coverage
.next/
@@ -42,7 +43,6 @@ test/tracetesting/tracetesting-vars.yaml
# Ignore copied/generated protobuf files
/src/accounting/src/protos/
-/src/cart/src/protos/
/src/fraud-detection/src/main/proto
/src/payment/demo.proto
/src/shipping/proto/
diff --git a/docker-compose.minimal.yml b/docker-compose.minimal.yml
index 9921830b9b..6f95da5e8a 100644
--- a/docker-compose.minimal.yml
+++ b/docker-compose.minimal.yml
@@ -74,7 +74,6 @@ services:
- OTEL_EXPORTER_OTLP_ENDPOINT
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_SERVICE_NAME=cart
- - ASPNETCORE_URLS=http://*:${CART_PORT}
depends_on:
valkey-cart:
condition: service_started
diff --git a/docker-compose.yml b/docker-compose.yml
index d8549520bb..9ee1130196 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -106,7 +106,6 @@ services:
- OTEL_EXPORTER_OTLP_ENDPOINT
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_SERVICE_NAME=cart
- - ASPNETCORE_URLS=http://*:${CART_PORT}
depends_on:
valkey-cart:
condition: service_started
diff --git a/docker-gen-proto.sh b/docker-gen-proto.sh
index ed2e3032c5..6dc64db660 100755
--- a/docker-gen-proto.sh
+++ b/docker-gen-proto.sh
@@ -43,10 +43,24 @@ gen_proto_ts() {
/build/pb/demo.proto'
}
+gen_proto_swift() {
+ echo "Generating Swift protobuf files for $1"
+ docker build -f "src/$1/genproto/Dockerfile" -t "$1-genproto" .
+ docker run --rm -e SERVICE=$1 -v $(pwd):/build "$1-genproto" /bin/sh -c '
+ mkdir -p /build/src/$SERVICE/Sources/CTL/Generated && \
+ protoc -I /build/pb \
+ --plugin="$(swift build --show-bin-path)/protoc-gen-swift" \
+ --plugin="$(swift build --show-bin-path)/protoc-gen-grpc-swift-2" \
+ --swift_out="/build/src/$SERVICE/Sources/CTL/Generated" \
+ --grpc-swift-2_opt=Client=false \
+ --grpc-swift-2_out="/build/src/$SERVICE/Sources/CTL/Generated" \
+ /build/pb/demo.proto'
+}
+
if [ -z "$1" ]; then
#gen_proto_dotnet accounting
#gen_proto_java ad
- #gen_proto_dotnet cart
+ gen_proto_swift cart
gen_proto_go checkout
gen_proto_cpp currency
#gen_proto_ruby email
diff --git a/src/cart/.dockerignore b/src/cart/.dockerignore
new file mode 100644
index 0000000000..3de0d9ffb4
--- /dev/null
+++ b/src/cart/.dockerignore
@@ -0,0 +1,3 @@
+**/.build/
+**/.swiftpm/
+Dockerfile*
diff --git a/src/cart/Dockerfile b/src/cart/Dockerfile
new file mode 100644
index 0000000000..a447dae164
--- /dev/null
+++ b/src/cart/Dockerfile
@@ -0,0 +1,75 @@
+# ================================
+# Build image
+# ================================
+FROM swift:6.1-noble AS build
+
+# Install OS updates
+RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
+ && apt-get -q update \
+ && apt-get -q dist-upgrade -y \
+ && apt-get install -y libjemalloc-dev \
+ && rm -rf /var/lib/apt/lists/*
+
+# Set up a build area
+WORKDIR /build
+
+# First just resolve dependencies.
+# This creates a cached layer that can be reused
+# as long as your Package.swift/Package.resolved
+# files do not change.
+COPY ./src/cart/Package.* ./
+RUN swift package resolve
+
+# Copy entire repo into container
+COPY ./src/cart .
+
+# Build the application, with optimizations, with static linking, and using jemalloc
+RUN swift build -c release \
+ --product "cart" \
+ --static-swift-stdlib \
+ -Xlinker -ljemalloc
+
+# Switch to the staging area
+WORKDIR /staging
+
+# Copy main executable to staging area
+RUN cp "$(swift build --package-path /build -c release --show-bin-path)/cart" ./
+
+# Copy static swift backtracer binary to staging area
+RUN cp "/usr/libexec/swift/linux/swift-backtrace-static" ./
+
+# ================================
+# Run image
+# ================================
+FROM ubuntu:noble
+
+# Make sure all system packages are up to date, and install only essential packages.
+RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
+ && apt-get -q update \
+ && apt-get -q dist-upgrade -y \
+ && apt-get -q install -y \
+ libjemalloc2 \
+ ca-certificates \
+ tzdata \
+ && rm -r /var/lib/apt/lists/*
+
+# Create a cart user and group with /app as its home directory
+RUN useradd --user-group --create-home --system --skel /dev/null --home-dir /app cart
+
+# Switch to the new home directory
+WORKDIR /app
+
+# Copy built executable and any staged resources from builder
+COPY --from=build --chown=cart:cart /staging /app
+
+# Provide configuration needed by the built-in crash reporter and some sensible default behaviors.
+ENV SWIFT_BACKTRACE=enable=yes,sanitize=yes,threads=all,images=all,interactive=no,swift-backtrace=./swift-backtrace-static
+
+# Ensure all further commands run as the cart user
+USER cart:cart
+
+# Let Docker bind to the cart port
+EXPOSE ${CART_PORT}
+
+# Start the cart service when the image is run
+ENTRYPOINT ["./cart"]
diff --git a/src/cart/Package.resolved b/src/cart/Package.resolved
new file mode 100644
index 0000000000..86bce62271
--- /dev/null
+++ b/src/cart/Package.resolved
@@ -0,0 +1,240 @@
+{
+ "originHash" : "842009160bb374b495b4745aba76215ab2e8449fb7cdcdcfb4b02bcfc0a1d758",
+ "pins" : [
+ {
+ "identity" : "grpc-swift-2",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/grpc/grpc-swift-2.git",
+ "state" : {
+ "revision" : "0e52abf7ea0fca7ffe876953aa41feff84cc6e29",
+ "version" : "2.1.0"
+ }
+ },
+ {
+ "identity" : "grpc-swift-extras",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/grpc/grpc-swift-extras.git",
+ "state" : {
+ "revision" : "dd34dae247c0b49db0e81dca5da64033b02cb49c",
+ "version" : "2.0.0"
+ }
+ },
+ {
+ "identity" : "grpc-swift-nio-transport",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/grpc/grpc-swift-nio-transport.git",
+ "state" : {
+ "revision" : "108495b705a68f6931281a96156532029ff8b9ed",
+ "version" : "2.1.1"
+ }
+ },
+ {
+ "identity" : "grpc-swift-protobuf",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/grpc/grpc-swift-protobuf.git",
+ "state" : {
+ "revision" : "c008d356d9e9c2255602711888bf25b542a30919",
+ "version" : "2.1.1"
+ }
+ },
+ {
+ "identity" : "swift-algorithms",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-algorithms.git",
+ "state" : {
+ "revision" : "87e50f483c54e6efd60e885f7f5aa946cee68023",
+ "version" : "1.2.1"
+ }
+ },
+ {
+ "identity" : "swift-argument-parser",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-argument-parser.git",
+ "state" : {
+ "revision" : "309a47b2b1d9b5e991f36961c983ecec72275be3",
+ "version" : "1.6.1"
+ }
+ },
+ {
+ "identity" : "swift-asn1",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-asn1.git",
+ "state" : {
+ "revision" : "f70225981241859eb4aa1a18a75531d26637c8cc",
+ "version" : "1.4.0"
+ }
+ },
+ {
+ "identity" : "swift-async-algorithms",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-async-algorithms.git",
+ "state" : {
+ "revision" : "042e1c4d9d19748c9c228f8d4ebc97bb1e339b0b",
+ "version" : "1.0.4"
+ }
+ },
+ {
+ "identity" : "swift-atomics",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-atomics.git",
+ "state" : {
+ "revision" : "b601256eab081c0f92f059e12818ac1d4f178ff7",
+ "version" : "1.3.0"
+ }
+ },
+ {
+ "identity" : "swift-certificates",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-certificates.git",
+ "state" : {
+ "revision" : "20c451f1ad8e344e61ddbb34ef196653d4b73ea6",
+ "version" : "1.13.0"
+ }
+ },
+ {
+ "identity" : "swift-collections",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-collections.git",
+ "state" : {
+ "revision" : "8c0c0a8b49e080e54e5e328cc552821ff07cd341",
+ "version" : "1.2.1"
+ }
+ },
+ {
+ "identity" : "swift-crypto",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-crypto.git",
+ "state" : {
+ "revision" : "d1c6b70f7c5f19fb0b8750cb8dcdf2ea6e2d8c34",
+ "version" : "3.15.0"
+ }
+ },
+ {
+ "identity" : "swift-distributed-tracing",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-distributed-tracing.git",
+ "state" : {
+ "revision" : "149fa4cc7d54c513288108142e7af9ceaf8def8f",
+ "version" : "1.2.2"
+ }
+ },
+ {
+ "identity" : "swift-http-structured-headers",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-http-structured-headers.git",
+ "state" : {
+ "revision" : "1625f271afb04375bf48737a5572613248d0e7a0",
+ "version" : "1.4.0"
+ }
+ },
+ {
+ "identity" : "swift-http-types",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-http-types.git",
+ "state" : {
+ "revision" : "a0a57e949a8903563aba4615869310c0ebf14c03",
+ "version" : "1.4.0"
+ }
+ },
+ {
+ "identity" : "swift-log",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-log.git",
+ "state" : {
+ "revision" : "ce592ae52f982c847a4efc0dd881cc9eb32d29f2",
+ "version" : "1.6.4"
+ }
+ },
+ {
+ "identity" : "swift-nio",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-nio.git",
+ "state" : {
+ "revision" : "1c30f0f2053b654e3d1302492124aa6d242cdba7",
+ "version" : "2.86.0"
+ }
+ },
+ {
+ "identity" : "swift-nio-extras",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-nio-extras.git",
+ "state" : {
+ "revision" : "a55c3dd3a81d035af8a20ce5718889c0dcab073d",
+ "version" : "1.29.0"
+ }
+ },
+ {
+ "identity" : "swift-nio-http2",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-nio-http2.git",
+ "state" : {
+ "revision" : "5e9e99ec96c53bc2c18ddd10c1e25a3cd97c55e5",
+ "version" : "1.38.0"
+ }
+ },
+ {
+ "identity" : "swift-nio-ssl",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-nio-ssl.git",
+ "state" : {
+ "revision" : "737e550e607d82bf15bdfddf158ec61652ce836f",
+ "version" : "2.34.0"
+ }
+ },
+ {
+ "identity" : "swift-nio-transport-services",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-nio-transport-services.git",
+ "state" : {
+ "revision" : "e645014baea2ec1c2db564410c51a656cf47c923",
+ "version" : "1.25.1"
+ }
+ },
+ {
+ "identity" : "swift-numerics",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-numerics.git",
+ "state" : {
+ "revision" : "bbadd4b853a33fd78c4ae977d17bb2af15eb3f2a",
+ "version" : "1.1.0"
+ }
+ },
+ {
+ "identity" : "swift-protobuf",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-protobuf.git",
+ "state" : {
+ "revision" : "e3f69fd321d0c9fcdc16fb576a0cdd956675face",
+ "version" : "1.31.0"
+ }
+ },
+ {
+ "identity" : "swift-service-context",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-service-context.git",
+ "state" : {
+ "revision" : "1983448fefc717a2bc2ebde5490fe99873c5b8a6",
+ "version" : "1.2.1"
+ }
+ },
+ {
+ "identity" : "swift-service-lifecycle",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/swift-server/swift-service-lifecycle.git",
+ "state" : {
+ "revision" : "e7187309187695115033536e8fc9b2eb87fd956d",
+ "version" : "2.8.0"
+ }
+ },
+ {
+ "identity" : "swift-system",
+ "kind" : "remoteSourceControl",
+ "location" : "https://github.com/apple/swift-system.git",
+ "state" : {
+ "revision" : "890830fff1a577dc83134890c7984020c5f6b43b",
+ "version" : "1.6.2"
+ }
+ }
+ ],
+ "version" : 3
+}
diff --git a/src/cart/Package.swift b/src/cart/Package.swift
new file mode 100644
index 0000000000..76b9f39941
--- /dev/null
+++ b/src/cart/Package.swift
@@ -0,0 +1,32 @@
+// swift-tools-version:6.1
+import PackageDescription
+
+let package = Package(
+ name: "cart",
+ platforms: [.macOS(.v15)],
+ products: [
+ .executable(name: "cart", targets: ["CTL"])
+ ],
+ dependencies: [
+ .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.0.0"),
+ .package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.0.0"),
+ .package(url: "https://github.com/grpc/grpc-swift-2.git", from: "2.0.0"),
+ .package(url: "https://github.com/grpc/grpc-swift-protobuf.git", from: "2.0.0"),
+ .package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", from: "2.0.0"),
+ .package(url: "https://github.com/grpc/grpc-swift-extras.git", from: "2.0.0"),
+ ],
+ targets: [
+ .executableTarget(
+ name: "CTL",
+ dependencies: [
+ .product(name: "ArgumentParser", package: "swift-argument-parser"),
+ .product(name: "ServiceLifecycle", package: "swift-service-lifecycle"),
+ .product(name: "GRPCCore", package: "grpc-swift-2"),
+ .product(name: "GRPCNIOTransportHTTP2", package: "grpc-swift-nio-transport"),
+ .product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
+ .product(name: "GRPCServiceLifecycle", package: "grpc-swift-extras"),
+ ]
+ )
+ ],
+ swiftLanguageModes: [.v6]
+)
diff --git a/src/cart/README.md b/src/cart/README.md
index f2b2db6484..1f9738da40 100644
--- a/src/cart/README.md
+++ b/src/cart/README.md
@@ -4,7 +4,7 @@ This service stores user shopping carts in Valkey.
## Local Build
-Run `dotnet restore` and `dotnet build`.
+Run `swift build`.
## Docker Build
diff --git a/src/cart/Sources/CTL/CartCTL.swift b/src/cart/Sources/CTL/CartCTL.swift
new file mode 100644
index 0000000000..ff19068de8
--- /dev/null
+++ b/src/cart/Sources/CTL/CartCTL.swift
@@ -0,0 +1,62 @@
+import ArgumentParser
+import Foundation
+import Logging
+import GRPCCore
+import GRPCNIOTransportHTTP2
+import ServiceLifecycle
+import GRPCServiceLifecycle
+
+@main
+struct CartCTL: AsyncParsableCommand {
+ func run() async throws {
+ let port = ProcessInfo.processInfo.environment["CART_PORT"].flatMap(Int.init) ?? 8080
+
+ let service = CartService()
+ let server = GRPCServer(
+ transport: .http2NIOPosix(
+ address: .ipv4(host: "0.0.0.0", port: port),
+ transportSecurity: .plaintext
+ ),
+ services: [service]
+ )
+
+ let serviceGroup = ServiceGroup(
+ services: [server],
+ gracefulShutdownSignals: [.sigint, .sigterm],
+ logger: Logger(label: "cart")
+ )
+
+ try await serviceGroup.run()
+ }
+}
+
+struct CartService: Oteldemo_CartService.SimpleServiceProtocol {
+ func addItem(
+ request: Oteldemo_AddItemRequest,
+ context: ServerContext
+ ) async throws -> Oteldemo_Empty {
+ Oteldemo_Empty()
+ }
+
+ func getCart(
+ request: Oteldemo_GetCartRequest,
+ context: ServerContext
+ ) async throws -> Oteldemo_Cart {
+ var cart = Oteldemo_Cart()
+ cart.userID = request.userID
+ cart.items = [
+ .with {
+ $0.productID = "OLJCESPC7Z"
+ $0.quantity = 1
+ }
+ ]
+ return cart
+ }
+
+ func emptyCart(
+ request: Oteldemo_EmptyCartRequest,
+ context: ServerContext
+ ) async throws -> Oteldemo_Empty {
+ Oteldemo_Empty()
+ }
+}
diff --git a/src/cart/Sources/CTL/Generated/demo.grpc.swift b/src/cart/Sources/CTL/Generated/demo.grpc.swift
new file mode 100644
index 0000000000..0f6da06516
--- /dev/null
+++ b/src/cart/Sources/CTL/Generated/demo.grpc.swift
@@ -0,0 +1,2516 @@
+// Copyright 2020 Google LLC
+//
+// 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.
+
+// DO NOT EDIT.
+// swift-format-ignore-file
+// swiftlint:disable all
+//
+// Generated by the gRPC Swift generator plugin for the protocol buffer compiler.
+// Source: demo.proto
+//
+// For information on using the generated types, please see the documentation:
+// https://github.com/grpc/grpc-swift
+
+import GRPCCore
+import GRPCProtobuf
+
+// MARK: - oteldemo.CartService
+
+/// Namespace containing generated types for the "oteldemo.CartService" service.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+internal enum Oteldemo_CartService {
+ /// Service descriptor for the "oteldemo.CartService" service.
+ internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.CartService")
+ /// Namespace for method metadata.
+ internal enum Method {
+ /// Namespace for "AddItem" metadata.
+ internal enum AddItem {
+ /// Request type for "AddItem".
+ internal typealias Input = Oteldemo_AddItemRequest
+ /// Response type for "AddItem".
+ internal typealias Output = Oteldemo_Empty
+ /// Descriptor for "AddItem".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.CartService"),
+ method: "AddItem"
+ )
+ }
+ /// Namespace for "GetCart" metadata.
+ internal enum GetCart {
+ /// Request type for "GetCart".
+ internal typealias Input = Oteldemo_GetCartRequest
+ /// Response type for "GetCart".
+ internal typealias Output = Oteldemo_Cart
+ /// Descriptor for "GetCart".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.CartService"),
+ method: "GetCart"
+ )
+ }
+ /// Namespace for "EmptyCart" metadata.
+ internal enum EmptyCart {
+ /// Request type for "EmptyCart".
+ internal typealias Input = Oteldemo_EmptyCartRequest
+ /// Response type for "EmptyCart".
+ internal typealias Output = Oteldemo_Empty
+ /// Descriptor for "EmptyCart".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.CartService"),
+ method: "EmptyCart"
+ )
+ }
+ /// Descriptors for all methods in the "oteldemo.CartService" service.
+ internal static let descriptors: [GRPCCore.MethodDescriptor] = [
+ AddItem.descriptor,
+ GetCart.descriptor,
+ EmptyCart.descriptor
+ ]
+ }
+}
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension GRPCCore.ServiceDescriptor {
+ /// Service descriptor for the "oteldemo.CartService" service.
+ internal static let oteldemo_CartService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.CartService")
+}
+
+// MARK: oteldemo.CartService (server)
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_CartService {
+ /// Streaming variant of the service protocol for the "oteldemo.CartService" service.
+ ///
+ /// This protocol is the lowest-level of the service protocols generated for this service
+ /// giving you the most flexibility over the implementation of your service. This comes at
+ /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in
+ /// terms of a request stream and response stream. Where only a single request or response
+ /// message is expected, you are responsible for enforcing this invariant is maintained.
+ ///
+ /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol``
+ /// or ``SimpleServiceProtocol`` instead.
+ internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
+ /// Handle the "AddItem" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_AddItemRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_Empty` messages.
+ func addItem(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+
+ /// Handle the "GetCart" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_GetCartRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_Cart` messages.
+ func getCart(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+
+ /// Handle the "EmptyCart" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_EmptyCartRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_Empty` messages.
+ func emptyCart(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+ }
+
+ /// Service protocol for the "oteldemo.CartService" service.
+ ///
+ /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than
+ /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and
+ /// trailing response metadata. If you don't need these then consider using
+ /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then
+ /// use ``StreamingServiceProtocol``.
+ internal protocol ServiceProtocol: Oteldemo_CartService.StreamingServiceProtocol {
+ /// Handle the "AddItem" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_AddItemRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_Empty` message.
+ func addItem(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+
+ /// Handle the "GetCart" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_GetCartRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_Cart` message.
+ func getCart(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+
+ /// Handle the "EmptyCart" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_EmptyCartRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_Empty` message.
+ func emptyCart(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+ }
+
+ /// Simple service protocol for the "oteldemo.CartService" service.
+ ///
+ /// This is the highest level protocol for the service. The API is the easiest to use but
+ /// doesn't provide access to request or response metadata. If you need access to these
+ /// then use ``ServiceProtocol`` instead.
+ internal protocol SimpleServiceProtocol: Oteldemo_CartService.ServiceProtocol {
+ /// Handle the "AddItem" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_AddItemRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_Empty` to respond with.
+ func addItem(
+ request: Oteldemo_AddItemRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_Empty
+
+ /// Handle the "GetCart" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_GetCartRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_Cart` to respond with.
+ func getCart(
+ request: Oteldemo_GetCartRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_Cart
+
+ /// Handle the "EmptyCart" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_EmptyCartRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_Empty` to respond with.
+ func emptyCart(
+ request: Oteldemo_EmptyCartRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_Empty
+ }
+}
+
+// Default implementation of 'registerMethods(with:)'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_CartService.StreamingServiceProtocol {
+ internal func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport {
+ router.registerHandler(
+ forMethod: Oteldemo_CartService.Method.AddItem.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.addItem(
+ request: request,
+ context: context
+ )
+ }
+ )
+ router.registerHandler(
+ forMethod: Oteldemo_CartService.Method.GetCart.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.getCart(
+ request: request,
+ context: context
+ )
+ }
+ )
+ router.registerHandler(
+ forMethod: Oteldemo_CartService.Method.EmptyCart.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.emptyCart(
+ request: request,
+ context: context
+ )
+ }
+ )
+ }
+}
+
+// Default implementation of streaming methods from 'StreamingServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_CartService.ServiceProtocol {
+ internal func addItem(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.addItem(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+
+ internal func getCart(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.getCart(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+
+ internal func emptyCart(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.emptyCart(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+}
+
+// Default implementation of methods from 'ServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_CartService.SimpleServiceProtocol {
+ internal func addItem(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.addItem(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+
+ internal func getCart(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.getCart(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+
+ internal func emptyCart(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.emptyCart(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+}
+
+// MARK: - oteldemo.RecommendationService
+
+/// Namespace containing generated types for the "oteldemo.RecommendationService" service.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+internal enum Oteldemo_RecommendationService {
+ /// Service descriptor for the "oteldemo.RecommendationService" service.
+ internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.RecommendationService")
+ /// Namespace for method metadata.
+ internal enum Method {
+ /// Namespace for "ListRecommendations" metadata.
+ internal enum ListRecommendations {
+ /// Request type for "ListRecommendations".
+ internal typealias Input = Oteldemo_ListRecommendationsRequest
+ /// Response type for "ListRecommendations".
+ internal typealias Output = Oteldemo_ListRecommendationsResponse
+ /// Descriptor for "ListRecommendations".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.RecommendationService"),
+ method: "ListRecommendations"
+ )
+ }
+ /// Descriptors for all methods in the "oteldemo.RecommendationService" service.
+ internal static let descriptors: [GRPCCore.MethodDescriptor] = [
+ ListRecommendations.descriptor
+ ]
+ }
+}
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension GRPCCore.ServiceDescriptor {
+ /// Service descriptor for the "oteldemo.RecommendationService" service.
+ internal static let oteldemo_RecommendationService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.RecommendationService")
+}
+
+// MARK: oteldemo.RecommendationService (server)
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_RecommendationService {
+ /// Streaming variant of the service protocol for the "oteldemo.RecommendationService" service.
+ ///
+ /// This protocol is the lowest-level of the service protocols generated for this service
+ /// giving you the most flexibility over the implementation of your service. This comes at
+ /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in
+ /// terms of a request stream and response stream. Where only a single request or response
+ /// message is expected, you are responsible for enforcing this invariant is maintained.
+ ///
+ /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol``
+ /// or ``SimpleServiceProtocol`` instead.
+ internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
+ /// Handle the "ListRecommendations" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_ListRecommendationsRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_ListRecommendationsResponse` messages.
+ func listRecommendations(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+ }
+
+ /// Service protocol for the "oteldemo.RecommendationService" service.
+ ///
+ /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than
+ /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and
+ /// trailing response metadata. If you don't need these then consider using
+ /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then
+ /// use ``StreamingServiceProtocol``.
+ internal protocol ServiceProtocol: Oteldemo_RecommendationService.StreamingServiceProtocol {
+ /// Handle the "ListRecommendations" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_ListRecommendationsRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_ListRecommendationsResponse` message.
+ func listRecommendations(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+ }
+
+ /// Simple service protocol for the "oteldemo.RecommendationService" service.
+ ///
+ /// This is the highest level protocol for the service. The API is the easiest to use but
+ /// doesn't provide access to request or response metadata. If you need access to these
+ /// then use ``ServiceProtocol`` instead.
+ internal protocol SimpleServiceProtocol: Oteldemo_RecommendationService.ServiceProtocol {
+ /// Handle the "ListRecommendations" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_ListRecommendationsRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_ListRecommendationsResponse` to respond with.
+ func listRecommendations(
+ request: Oteldemo_ListRecommendationsRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_ListRecommendationsResponse
+ }
+}
+
+// Default implementation of 'registerMethods(with:)'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_RecommendationService.StreamingServiceProtocol {
+ internal func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport {
+ router.registerHandler(
+ forMethod: Oteldemo_RecommendationService.Method.ListRecommendations.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.listRecommendations(
+ request: request,
+ context: context
+ )
+ }
+ )
+ }
+}
+
+// Default implementation of streaming methods from 'StreamingServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_RecommendationService.ServiceProtocol {
+ internal func listRecommendations(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.listRecommendations(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+}
+
+// Default implementation of methods from 'ServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_RecommendationService.SimpleServiceProtocol {
+ internal func listRecommendations(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.listRecommendations(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+}
+
+// MARK: - oteldemo.ProductCatalogService
+
+/// Namespace containing generated types for the "oteldemo.ProductCatalogService" service.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+internal enum Oteldemo_ProductCatalogService {
+ /// Service descriptor for the "oteldemo.ProductCatalogService" service.
+ internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.ProductCatalogService")
+ /// Namespace for method metadata.
+ internal enum Method {
+ /// Namespace for "ListProducts" metadata.
+ internal enum ListProducts {
+ /// Request type for "ListProducts".
+ internal typealias Input = Oteldemo_Empty
+ /// Response type for "ListProducts".
+ internal typealias Output = Oteldemo_ListProductsResponse
+ /// Descriptor for "ListProducts".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.ProductCatalogService"),
+ method: "ListProducts"
+ )
+ }
+ /// Namespace for "GetProduct" metadata.
+ internal enum GetProduct {
+ /// Request type for "GetProduct".
+ internal typealias Input = Oteldemo_GetProductRequest
+ /// Response type for "GetProduct".
+ internal typealias Output = Oteldemo_Product
+ /// Descriptor for "GetProduct".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.ProductCatalogService"),
+ method: "GetProduct"
+ )
+ }
+ /// Namespace for "SearchProducts" metadata.
+ internal enum SearchProducts {
+ /// Request type for "SearchProducts".
+ internal typealias Input = Oteldemo_SearchProductsRequest
+ /// Response type for "SearchProducts".
+ internal typealias Output = Oteldemo_SearchProductsResponse
+ /// Descriptor for "SearchProducts".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.ProductCatalogService"),
+ method: "SearchProducts"
+ )
+ }
+ /// Descriptors for all methods in the "oteldemo.ProductCatalogService" service.
+ internal static let descriptors: [GRPCCore.MethodDescriptor] = [
+ ListProducts.descriptor,
+ GetProduct.descriptor,
+ SearchProducts.descriptor
+ ]
+ }
+}
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension GRPCCore.ServiceDescriptor {
+ /// Service descriptor for the "oteldemo.ProductCatalogService" service.
+ internal static let oteldemo_ProductCatalogService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.ProductCatalogService")
+}
+
+// MARK: oteldemo.ProductCatalogService (server)
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_ProductCatalogService {
+ /// Streaming variant of the service protocol for the "oteldemo.ProductCatalogService" service.
+ ///
+ /// This protocol is the lowest-level of the service protocols generated for this service
+ /// giving you the most flexibility over the implementation of your service. This comes at
+ /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in
+ /// terms of a request stream and response stream. Where only a single request or response
+ /// message is expected, you are responsible for enforcing this invariant is maintained.
+ ///
+ /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol``
+ /// or ``SimpleServiceProtocol`` instead.
+ internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
+ /// Handle the "ListProducts" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_Empty` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_ListProductsResponse` messages.
+ func listProducts(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+
+ /// Handle the "GetProduct" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_GetProductRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_Product` messages.
+ func getProduct(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+
+ /// Handle the "SearchProducts" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_SearchProductsRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_SearchProductsResponse` messages.
+ func searchProducts(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+ }
+
+ /// Service protocol for the "oteldemo.ProductCatalogService" service.
+ ///
+ /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than
+ /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and
+ /// trailing response metadata. If you don't need these then consider using
+ /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then
+ /// use ``StreamingServiceProtocol``.
+ internal protocol ServiceProtocol: Oteldemo_ProductCatalogService.StreamingServiceProtocol {
+ /// Handle the "ListProducts" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_Empty` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_ListProductsResponse` message.
+ func listProducts(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+
+ /// Handle the "GetProduct" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_GetProductRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_Product` message.
+ func getProduct(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+
+ /// Handle the "SearchProducts" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_SearchProductsRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_SearchProductsResponse` message.
+ func searchProducts(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+ }
+
+ /// Simple service protocol for the "oteldemo.ProductCatalogService" service.
+ ///
+ /// This is the highest level protocol for the service. The API is the easiest to use but
+ /// doesn't provide access to request or response metadata. If you need access to these
+ /// then use ``ServiceProtocol`` instead.
+ internal protocol SimpleServiceProtocol: Oteldemo_ProductCatalogService.ServiceProtocol {
+ /// Handle the "ListProducts" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_Empty` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_ListProductsResponse` to respond with.
+ func listProducts(
+ request: Oteldemo_Empty,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_ListProductsResponse
+
+ /// Handle the "GetProduct" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_GetProductRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_Product` to respond with.
+ func getProduct(
+ request: Oteldemo_GetProductRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_Product
+
+ /// Handle the "SearchProducts" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_SearchProductsRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_SearchProductsResponse` to respond with.
+ func searchProducts(
+ request: Oteldemo_SearchProductsRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_SearchProductsResponse
+ }
+}
+
+// Default implementation of 'registerMethods(with:)'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_ProductCatalogService.StreamingServiceProtocol {
+ internal func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport {
+ router.registerHandler(
+ forMethod: Oteldemo_ProductCatalogService.Method.ListProducts.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.listProducts(
+ request: request,
+ context: context
+ )
+ }
+ )
+ router.registerHandler(
+ forMethod: Oteldemo_ProductCatalogService.Method.GetProduct.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.getProduct(
+ request: request,
+ context: context
+ )
+ }
+ )
+ router.registerHandler(
+ forMethod: Oteldemo_ProductCatalogService.Method.SearchProducts.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.searchProducts(
+ request: request,
+ context: context
+ )
+ }
+ )
+ }
+}
+
+// Default implementation of streaming methods from 'StreamingServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_ProductCatalogService.ServiceProtocol {
+ internal func listProducts(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.listProducts(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+
+ internal func getProduct(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.getProduct(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+
+ internal func searchProducts(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.searchProducts(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+}
+
+// Default implementation of methods from 'ServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_ProductCatalogService.SimpleServiceProtocol {
+ internal func listProducts(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.listProducts(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+
+ internal func getProduct(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.getProduct(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+
+ internal func searchProducts(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.searchProducts(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+}
+
+// MARK: - oteldemo.ShippingService
+
+/// Namespace containing generated types for the "oteldemo.ShippingService" service.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+internal enum Oteldemo_ShippingService {
+ /// Service descriptor for the "oteldemo.ShippingService" service.
+ internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.ShippingService")
+ /// Namespace for method metadata.
+ internal enum Method {
+ /// Namespace for "GetQuote" metadata.
+ internal enum GetQuote {
+ /// Request type for "GetQuote".
+ internal typealias Input = Oteldemo_GetQuoteRequest
+ /// Response type for "GetQuote".
+ internal typealias Output = Oteldemo_GetQuoteResponse
+ /// Descriptor for "GetQuote".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.ShippingService"),
+ method: "GetQuote"
+ )
+ }
+ /// Namespace for "ShipOrder" metadata.
+ internal enum ShipOrder {
+ /// Request type for "ShipOrder".
+ internal typealias Input = Oteldemo_ShipOrderRequest
+ /// Response type for "ShipOrder".
+ internal typealias Output = Oteldemo_ShipOrderResponse
+ /// Descriptor for "ShipOrder".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.ShippingService"),
+ method: "ShipOrder"
+ )
+ }
+ /// Descriptors for all methods in the "oteldemo.ShippingService" service.
+ internal static let descriptors: [GRPCCore.MethodDescriptor] = [
+ GetQuote.descriptor,
+ ShipOrder.descriptor
+ ]
+ }
+}
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension GRPCCore.ServiceDescriptor {
+ /// Service descriptor for the "oteldemo.ShippingService" service.
+ internal static let oteldemo_ShippingService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.ShippingService")
+}
+
+// MARK: oteldemo.ShippingService (server)
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_ShippingService {
+ /// Streaming variant of the service protocol for the "oteldemo.ShippingService" service.
+ ///
+ /// This protocol is the lowest-level of the service protocols generated for this service
+ /// giving you the most flexibility over the implementation of your service. This comes at
+ /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in
+ /// terms of a request stream and response stream. Where only a single request or response
+ /// message is expected, you are responsible for enforcing this invariant is maintained.
+ ///
+ /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol``
+ /// or ``SimpleServiceProtocol`` instead.
+ internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
+ /// Handle the "GetQuote" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_GetQuoteRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_GetQuoteResponse` messages.
+ func getQuote(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+
+ /// Handle the "ShipOrder" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_ShipOrderRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_ShipOrderResponse` messages.
+ func shipOrder(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+ }
+
+ /// Service protocol for the "oteldemo.ShippingService" service.
+ ///
+ /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than
+ /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and
+ /// trailing response metadata. If you don't need these then consider using
+ /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then
+ /// use ``StreamingServiceProtocol``.
+ internal protocol ServiceProtocol: Oteldemo_ShippingService.StreamingServiceProtocol {
+ /// Handle the "GetQuote" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_GetQuoteRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_GetQuoteResponse` message.
+ func getQuote(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+
+ /// Handle the "ShipOrder" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_ShipOrderRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_ShipOrderResponse` message.
+ func shipOrder(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+ }
+
+ /// Simple service protocol for the "oteldemo.ShippingService" service.
+ ///
+ /// This is the highest level protocol for the service. The API is the easiest to use but
+ /// doesn't provide access to request or response metadata. If you need access to these
+ /// then use ``ServiceProtocol`` instead.
+ internal protocol SimpleServiceProtocol: Oteldemo_ShippingService.ServiceProtocol {
+ /// Handle the "GetQuote" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_GetQuoteRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_GetQuoteResponse` to respond with.
+ func getQuote(
+ request: Oteldemo_GetQuoteRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_GetQuoteResponse
+
+ /// Handle the "ShipOrder" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_ShipOrderRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_ShipOrderResponse` to respond with.
+ func shipOrder(
+ request: Oteldemo_ShipOrderRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_ShipOrderResponse
+ }
+}
+
+// Default implementation of 'registerMethods(with:)'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_ShippingService.StreamingServiceProtocol {
+ internal func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport {
+ router.registerHandler(
+ forMethod: Oteldemo_ShippingService.Method.GetQuote.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.getQuote(
+ request: request,
+ context: context
+ )
+ }
+ )
+ router.registerHandler(
+ forMethod: Oteldemo_ShippingService.Method.ShipOrder.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.shipOrder(
+ request: request,
+ context: context
+ )
+ }
+ )
+ }
+}
+
+// Default implementation of streaming methods from 'StreamingServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_ShippingService.ServiceProtocol {
+ internal func getQuote(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.getQuote(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+
+ internal func shipOrder(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.shipOrder(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+}
+
+// Default implementation of methods from 'ServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_ShippingService.SimpleServiceProtocol {
+ internal func getQuote(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.getQuote(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+
+ internal func shipOrder(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.shipOrder(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+}
+
+// MARK: - oteldemo.CurrencyService
+
+/// Namespace containing generated types for the "oteldemo.CurrencyService" service.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+internal enum Oteldemo_CurrencyService {
+ /// Service descriptor for the "oteldemo.CurrencyService" service.
+ internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.CurrencyService")
+ /// Namespace for method metadata.
+ internal enum Method {
+ /// Namespace for "GetSupportedCurrencies" metadata.
+ internal enum GetSupportedCurrencies {
+ /// Request type for "GetSupportedCurrencies".
+ internal typealias Input = Oteldemo_Empty
+ /// Response type for "GetSupportedCurrencies".
+ internal typealias Output = Oteldemo_GetSupportedCurrenciesResponse
+ /// Descriptor for "GetSupportedCurrencies".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.CurrencyService"),
+ method: "GetSupportedCurrencies"
+ )
+ }
+ /// Namespace for "Convert" metadata.
+ internal enum Convert {
+ /// Request type for "Convert".
+ internal typealias Input = Oteldemo_CurrencyConversionRequest
+ /// Response type for "Convert".
+ internal typealias Output = Oteldemo_Money
+ /// Descriptor for "Convert".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.CurrencyService"),
+ method: "Convert"
+ )
+ }
+ /// Descriptors for all methods in the "oteldemo.CurrencyService" service.
+ internal static let descriptors: [GRPCCore.MethodDescriptor] = [
+ GetSupportedCurrencies.descriptor,
+ Convert.descriptor
+ ]
+ }
+}
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension GRPCCore.ServiceDescriptor {
+ /// Service descriptor for the "oteldemo.CurrencyService" service.
+ internal static let oteldemo_CurrencyService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.CurrencyService")
+}
+
+// MARK: oteldemo.CurrencyService (server)
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_CurrencyService {
+ /// Streaming variant of the service protocol for the "oteldemo.CurrencyService" service.
+ ///
+ /// This protocol is the lowest-level of the service protocols generated for this service
+ /// giving you the most flexibility over the implementation of your service. This comes at
+ /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in
+ /// terms of a request stream and response stream. Where only a single request or response
+ /// message is expected, you are responsible for enforcing this invariant is maintained.
+ ///
+ /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol``
+ /// or ``SimpleServiceProtocol`` instead.
+ internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
+ /// Handle the "GetSupportedCurrencies" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_Empty` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_GetSupportedCurrenciesResponse` messages.
+ func getSupportedCurrencies(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+
+ /// Handle the "Convert" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_CurrencyConversionRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_Money` messages.
+ func convert(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+ }
+
+ /// Service protocol for the "oteldemo.CurrencyService" service.
+ ///
+ /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than
+ /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and
+ /// trailing response metadata. If you don't need these then consider using
+ /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then
+ /// use ``StreamingServiceProtocol``.
+ internal protocol ServiceProtocol: Oteldemo_CurrencyService.StreamingServiceProtocol {
+ /// Handle the "GetSupportedCurrencies" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_Empty` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_GetSupportedCurrenciesResponse` message.
+ func getSupportedCurrencies(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+
+ /// Handle the "Convert" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_CurrencyConversionRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_Money` message.
+ func convert(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+ }
+
+ /// Simple service protocol for the "oteldemo.CurrencyService" service.
+ ///
+ /// This is the highest level protocol for the service. The API is the easiest to use but
+ /// doesn't provide access to request or response metadata. If you need access to these
+ /// then use ``ServiceProtocol`` instead.
+ internal protocol SimpleServiceProtocol: Oteldemo_CurrencyService.ServiceProtocol {
+ /// Handle the "GetSupportedCurrencies" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_Empty` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_GetSupportedCurrenciesResponse` to respond with.
+ func getSupportedCurrencies(
+ request: Oteldemo_Empty,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_GetSupportedCurrenciesResponse
+
+ /// Handle the "Convert" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_CurrencyConversionRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_Money` to respond with.
+ func convert(
+ request: Oteldemo_CurrencyConversionRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_Money
+ }
+}
+
+// Default implementation of 'registerMethods(with:)'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_CurrencyService.StreamingServiceProtocol {
+ internal func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport {
+ router.registerHandler(
+ forMethod: Oteldemo_CurrencyService.Method.GetSupportedCurrencies.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.getSupportedCurrencies(
+ request: request,
+ context: context
+ )
+ }
+ )
+ router.registerHandler(
+ forMethod: Oteldemo_CurrencyService.Method.Convert.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.convert(
+ request: request,
+ context: context
+ )
+ }
+ )
+ }
+}
+
+// Default implementation of streaming methods from 'StreamingServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_CurrencyService.ServiceProtocol {
+ internal func getSupportedCurrencies(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.getSupportedCurrencies(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+
+ internal func convert(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.convert(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+}
+
+// Default implementation of methods from 'ServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_CurrencyService.SimpleServiceProtocol {
+ internal func getSupportedCurrencies(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.getSupportedCurrencies(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+
+ internal func convert(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.convert(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+}
+
+// MARK: - oteldemo.PaymentService
+
+/// Namespace containing generated types for the "oteldemo.PaymentService" service.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+internal enum Oteldemo_PaymentService {
+ /// Service descriptor for the "oteldemo.PaymentService" service.
+ internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.PaymentService")
+ /// Namespace for method metadata.
+ internal enum Method {
+ /// Namespace for "Charge" metadata.
+ internal enum Charge {
+ /// Request type for "Charge".
+ internal typealias Input = Oteldemo_ChargeRequest
+ /// Response type for "Charge".
+ internal typealias Output = Oteldemo_ChargeResponse
+ /// Descriptor for "Charge".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.PaymentService"),
+ method: "Charge"
+ )
+ }
+ /// Descriptors for all methods in the "oteldemo.PaymentService" service.
+ internal static let descriptors: [GRPCCore.MethodDescriptor] = [
+ Charge.descriptor
+ ]
+ }
+}
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension GRPCCore.ServiceDescriptor {
+ /// Service descriptor for the "oteldemo.PaymentService" service.
+ internal static let oteldemo_PaymentService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.PaymentService")
+}
+
+// MARK: oteldemo.PaymentService (server)
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_PaymentService {
+ /// Streaming variant of the service protocol for the "oteldemo.PaymentService" service.
+ ///
+ /// This protocol is the lowest-level of the service protocols generated for this service
+ /// giving you the most flexibility over the implementation of your service. This comes at
+ /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in
+ /// terms of a request stream and response stream. Where only a single request or response
+ /// message is expected, you are responsible for enforcing this invariant is maintained.
+ ///
+ /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol``
+ /// or ``SimpleServiceProtocol`` instead.
+ internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
+ /// Handle the "Charge" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_ChargeRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_ChargeResponse` messages.
+ func charge(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+ }
+
+ /// Service protocol for the "oteldemo.PaymentService" service.
+ ///
+ /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than
+ /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and
+ /// trailing response metadata. If you don't need these then consider using
+ /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then
+ /// use ``StreamingServiceProtocol``.
+ internal protocol ServiceProtocol: Oteldemo_PaymentService.StreamingServiceProtocol {
+ /// Handle the "Charge" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_ChargeRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_ChargeResponse` message.
+ func charge(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+ }
+
+ /// Simple service protocol for the "oteldemo.PaymentService" service.
+ ///
+ /// This is the highest level protocol for the service. The API is the easiest to use but
+ /// doesn't provide access to request or response metadata. If you need access to these
+ /// then use ``ServiceProtocol`` instead.
+ internal protocol SimpleServiceProtocol: Oteldemo_PaymentService.ServiceProtocol {
+ /// Handle the "Charge" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_ChargeRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_ChargeResponse` to respond with.
+ func charge(
+ request: Oteldemo_ChargeRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_ChargeResponse
+ }
+}
+
+// Default implementation of 'registerMethods(with:)'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_PaymentService.StreamingServiceProtocol {
+ internal func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport {
+ router.registerHandler(
+ forMethod: Oteldemo_PaymentService.Method.Charge.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.charge(
+ request: request,
+ context: context
+ )
+ }
+ )
+ }
+}
+
+// Default implementation of streaming methods from 'StreamingServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_PaymentService.ServiceProtocol {
+ internal func charge(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.charge(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+}
+
+// Default implementation of methods from 'ServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_PaymentService.SimpleServiceProtocol {
+ internal func charge(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.charge(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+}
+
+// MARK: - oteldemo.EmailService
+
+/// Namespace containing generated types for the "oteldemo.EmailService" service.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+internal enum Oteldemo_EmailService {
+ /// Service descriptor for the "oteldemo.EmailService" service.
+ internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.EmailService")
+ /// Namespace for method metadata.
+ internal enum Method {
+ /// Namespace for "SendOrderConfirmation" metadata.
+ internal enum SendOrderConfirmation {
+ /// Request type for "SendOrderConfirmation".
+ internal typealias Input = Oteldemo_SendOrderConfirmationRequest
+ /// Response type for "SendOrderConfirmation".
+ internal typealias Output = Oteldemo_Empty
+ /// Descriptor for "SendOrderConfirmation".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.EmailService"),
+ method: "SendOrderConfirmation"
+ )
+ }
+ /// Descriptors for all methods in the "oteldemo.EmailService" service.
+ internal static let descriptors: [GRPCCore.MethodDescriptor] = [
+ SendOrderConfirmation.descriptor
+ ]
+ }
+}
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension GRPCCore.ServiceDescriptor {
+ /// Service descriptor for the "oteldemo.EmailService" service.
+ internal static let oteldemo_EmailService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.EmailService")
+}
+
+// MARK: oteldemo.EmailService (server)
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_EmailService {
+ /// Streaming variant of the service protocol for the "oteldemo.EmailService" service.
+ ///
+ /// This protocol is the lowest-level of the service protocols generated for this service
+ /// giving you the most flexibility over the implementation of your service. This comes at
+ /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in
+ /// terms of a request stream and response stream. Where only a single request or response
+ /// message is expected, you are responsible for enforcing this invariant is maintained.
+ ///
+ /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol``
+ /// or ``SimpleServiceProtocol`` instead.
+ internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
+ /// Handle the "SendOrderConfirmation" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_SendOrderConfirmationRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_Empty` messages.
+ func sendOrderConfirmation(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+ }
+
+ /// Service protocol for the "oteldemo.EmailService" service.
+ ///
+ /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than
+ /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and
+ /// trailing response metadata. If you don't need these then consider using
+ /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then
+ /// use ``StreamingServiceProtocol``.
+ internal protocol ServiceProtocol: Oteldemo_EmailService.StreamingServiceProtocol {
+ /// Handle the "SendOrderConfirmation" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_SendOrderConfirmationRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_Empty` message.
+ func sendOrderConfirmation(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+ }
+
+ /// Simple service protocol for the "oteldemo.EmailService" service.
+ ///
+ /// This is the highest level protocol for the service. The API is the easiest to use but
+ /// doesn't provide access to request or response metadata. If you need access to these
+ /// then use ``ServiceProtocol`` instead.
+ internal protocol SimpleServiceProtocol: Oteldemo_EmailService.ServiceProtocol {
+ /// Handle the "SendOrderConfirmation" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_SendOrderConfirmationRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_Empty` to respond with.
+ func sendOrderConfirmation(
+ request: Oteldemo_SendOrderConfirmationRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_Empty
+ }
+}
+
+// Default implementation of 'registerMethods(with:)'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_EmailService.StreamingServiceProtocol {
+ internal func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport {
+ router.registerHandler(
+ forMethod: Oteldemo_EmailService.Method.SendOrderConfirmation.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.sendOrderConfirmation(
+ request: request,
+ context: context
+ )
+ }
+ )
+ }
+}
+
+// Default implementation of streaming methods from 'StreamingServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_EmailService.ServiceProtocol {
+ internal func sendOrderConfirmation(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.sendOrderConfirmation(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+}
+
+// Default implementation of methods from 'ServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_EmailService.SimpleServiceProtocol {
+ internal func sendOrderConfirmation(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.sendOrderConfirmation(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+}
+
+// MARK: - oteldemo.CheckoutService
+
+/// Namespace containing generated types for the "oteldemo.CheckoutService" service.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+internal enum Oteldemo_CheckoutService {
+ /// Service descriptor for the "oteldemo.CheckoutService" service.
+ internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.CheckoutService")
+ /// Namespace for method metadata.
+ internal enum Method {
+ /// Namespace for "PlaceOrder" metadata.
+ internal enum PlaceOrder {
+ /// Request type for "PlaceOrder".
+ internal typealias Input = Oteldemo_PlaceOrderRequest
+ /// Response type for "PlaceOrder".
+ internal typealias Output = Oteldemo_PlaceOrderResponse
+ /// Descriptor for "PlaceOrder".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.CheckoutService"),
+ method: "PlaceOrder"
+ )
+ }
+ /// Descriptors for all methods in the "oteldemo.CheckoutService" service.
+ internal static let descriptors: [GRPCCore.MethodDescriptor] = [
+ PlaceOrder.descriptor
+ ]
+ }
+}
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension GRPCCore.ServiceDescriptor {
+ /// Service descriptor for the "oteldemo.CheckoutService" service.
+ internal static let oteldemo_CheckoutService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.CheckoutService")
+}
+
+// MARK: oteldemo.CheckoutService (server)
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_CheckoutService {
+ /// Streaming variant of the service protocol for the "oteldemo.CheckoutService" service.
+ ///
+ /// This protocol is the lowest-level of the service protocols generated for this service
+ /// giving you the most flexibility over the implementation of your service. This comes at
+ /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in
+ /// terms of a request stream and response stream. Where only a single request or response
+ /// message is expected, you are responsible for enforcing this invariant is maintained.
+ ///
+ /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol``
+ /// or ``SimpleServiceProtocol`` instead.
+ internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
+ /// Handle the "PlaceOrder" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_PlaceOrderRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_PlaceOrderResponse` messages.
+ func placeOrder(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+ }
+
+ /// Service protocol for the "oteldemo.CheckoutService" service.
+ ///
+ /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than
+ /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and
+ /// trailing response metadata. If you don't need these then consider using
+ /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then
+ /// use ``StreamingServiceProtocol``.
+ internal protocol ServiceProtocol: Oteldemo_CheckoutService.StreamingServiceProtocol {
+ /// Handle the "PlaceOrder" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_PlaceOrderRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_PlaceOrderResponse` message.
+ func placeOrder(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+ }
+
+ /// Simple service protocol for the "oteldemo.CheckoutService" service.
+ ///
+ /// This is the highest level protocol for the service. The API is the easiest to use but
+ /// doesn't provide access to request or response metadata. If you need access to these
+ /// then use ``ServiceProtocol`` instead.
+ internal protocol SimpleServiceProtocol: Oteldemo_CheckoutService.ServiceProtocol {
+ /// Handle the "PlaceOrder" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_PlaceOrderRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_PlaceOrderResponse` to respond with.
+ func placeOrder(
+ request: Oteldemo_PlaceOrderRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_PlaceOrderResponse
+ }
+}
+
+// Default implementation of 'registerMethods(with:)'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_CheckoutService.StreamingServiceProtocol {
+ internal func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport {
+ router.registerHandler(
+ forMethod: Oteldemo_CheckoutService.Method.PlaceOrder.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.placeOrder(
+ request: request,
+ context: context
+ )
+ }
+ )
+ }
+}
+
+// Default implementation of streaming methods from 'StreamingServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_CheckoutService.ServiceProtocol {
+ internal func placeOrder(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.placeOrder(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+}
+
+// Default implementation of methods from 'ServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_CheckoutService.SimpleServiceProtocol {
+ internal func placeOrder(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.placeOrder(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+}
+
+// MARK: - oteldemo.AdService
+
+/// Namespace containing generated types for the "oteldemo.AdService" service.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+internal enum Oteldemo_AdService {
+ /// Service descriptor for the "oteldemo.AdService" service.
+ internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.AdService")
+ /// Namespace for method metadata.
+ internal enum Method {
+ /// Namespace for "GetAds" metadata.
+ internal enum GetAds {
+ /// Request type for "GetAds".
+ internal typealias Input = Oteldemo_AdRequest
+ /// Response type for "GetAds".
+ internal typealias Output = Oteldemo_AdResponse
+ /// Descriptor for "GetAds".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.AdService"),
+ method: "GetAds"
+ )
+ }
+ /// Descriptors for all methods in the "oteldemo.AdService" service.
+ internal static let descriptors: [GRPCCore.MethodDescriptor] = [
+ GetAds.descriptor
+ ]
+ }
+}
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension GRPCCore.ServiceDescriptor {
+ /// Service descriptor for the "oteldemo.AdService" service.
+ internal static let oteldemo_AdService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.AdService")
+}
+
+// MARK: oteldemo.AdService (server)
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_AdService {
+ /// Streaming variant of the service protocol for the "oteldemo.AdService" service.
+ ///
+ /// This protocol is the lowest-level of the service protocols generated for this service
+ /// giving you the most flexibility over the implementation of your service. This comes at
+ /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in
+ /// terms of a request stream and response stream. Where only a single request or response
+ /// message is expected, you are responsible for enforcing this invariant is maintained.
+ ///
+ /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol``
+ /// or ``SimpleServiceProtocol`` instead.
+ internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
+ /// Handle the "GetAds" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_AdRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_AdResponse` messages.
+ func getAds(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+ }
+
+ /// Service protocol for the "oteldemo.AdService" service.
+ ///
+ /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than
+ /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and
+ /// trailing response metadata. If you don't need these then consider using
+ /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then
+ /// use ``StreamingServiceProtocol``.
+ internal protocol ServiceProtocol: Oteldemo_AdService.StreamingServiceProtocol {
+ /// Handle the "GetAds" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_AdRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_AdResponse` message.
+ func getAds(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+ }
+
+ /// Simple service protocol for the "oteldemo.AdService" service.
+ ///
+ /// This is the highest level protocol for the service. The API is the easiest to use but
+ /// doesn't provide access to request or response metadata. If you need access to these
+ /// then use ``ServiceProtocol`` instead.
+ internal protocol SimpleServiceProtocol: Oteldemo_AdService.ServiceProtocol {
+ /// Handle the "GetAds" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_AdRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_AdResponse` to respond with.
+ func getAds(
+ request: Oteldemo_AdRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_AdResponse
+ }
+}
+
+// Default implementation of 'registerMethods(with:)'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_AdService.StreamingServiceProtocol {
+ internal func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport {
+ router.registerHandler(
+ forMethod: Oteldemo_AdService.Method.GetAds.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.getAds(
+ request: request,
+ context: context
+ )
+ }
+ )
+ }
+}
+
+// Default implementation of streaming methods from 'StreamingServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_AdService.ServiceProtocol {
+ internal func getAds(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.getAds(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+}
+
+// Default implementation of methods from 'ServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_AdService.SimpleServiceProtocol {
+ internal func getAds(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.getAds(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+}
+
+// MARK: - oteldemo.FeatureFlagService
+
+/// Namespace containing generated types for the "oteldemo.FeatureFlagService" service.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+internal enum Oteldemo_FeatureFlagService {
+ /// Service descriptor for the "oteldemo.FeatureFlagService" service.
+ internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.FeatureFlagService")
+ /// Namespace for method metadata.
+ internal enum Method {
+ /// Namespace for "GetFlag" metadata.
+ internal enum GetFlag {
+ /// Request type for "GetFlag".
+ internal typealias Input = Oteldemo_GetFlagRequest
+ /// Response type for "GetFlag".
+ internal typealias Output = Oteldemo_GetFlagResponse
+ /// Descriptor for "GetFlag".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.FeatureFlagService"),
+ method: "GetFlag"
+ )
+ }
+ /// Namespace for "CreateFlag" metadata.
+ internal enum CreateFlag {
+ /// Request type for "CreateFlag".
+ internal typealias Input = Oteldemo_CreateFlagRequest
+ /// Response type for "CreateFlag".
+ internal typealias Output = Oteldemo_CreateFlagResponse
+ /// Descriptor for "CreateFlag".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.FeatureFlagService"),
+ method: "CreateFlag"
+ )
+ }
+ /// Namespace for "UpdateFlag" metadata.
+ internal enum UpdateFlag {
+ /// Request type for "UpdateFlag".
+ internal typealias Input = Oteldemo_UpdateFlagRequest
+ /// Response type for "UpdateFlag".
+ internal typealias Output = Oteldemo_UpdateFlagResponse
+ /// Descriptor for "UpdateFlag".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.FeatureFlagService"),
+ method: "UpdateFlag"
+ )
+ }
+ /// Namespace for "ListFlags" metadata.
+ internal enum ListFlags {
+ /// Request type for "ListFlags".
+ internal typealias Input = Oteldemo_ListFlagsRequest
+ /// Response type for "ListFlags".
+ internal typealias Output = Oteldemo_ListFlagsResponse
+ /// Descriptor for "ListFlags".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.FeatureFlagService"),
+ method: "ListFlags"
+ )
+ }
+ /// Namespace for "DeleteFlag" metadata.
+ internal enum DeleteFlag {
+ /// Request type for "DeleteFlag".
+ internal typealias Input = Oteldemo_DeleteFlagRequest
+ /// Response type for "DeleteFlag".
+ internal typealias Output = Oteldemo_DeleteFlagResponse
+ /// Descriptor for "DeleteFlag".
+ internal static let descriptor = GRPCCore.MethodDescriptor(
+ service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.FeatureFlagService"),
+ method: "DeleteFlag"
+ )
+ }
+ /// Descriptors for all methods in the "oteldemo.FeatureFlagService" service.
+ internal static let descriptors: [GRPCCore.MethodDescriptor] = [
+ GetFlag.descriptor,
+ CreateFlag.descriptor,
+ UpdateFlag.descriptor,
+ ListFlags.descriptor,
+ DeleteFlag.descriptor
+ ]
+ }
+}
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension GRPCCore.ServiceDescriptor {
+ /// Service descriptor for the "oteldemo.FeatureFlagService" service.
+ internal static let oteldemo_FeatureFlagService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "oteldemo.FeatureFlagService")
+}
+
+// MARK: oteldemo.FeatureFlagService (server)
+
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_FeatureFlagService {
+ /// Streaming variant of the service protocol for the "oteldemo.FeatureFlagService" service.
+ ///
+ /// This protocol is the lowest-level of the service protocols generated for this service
+ /// giving you the most flexibility over the implementation of your service. This comes at
+ /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in
+ /// terms of a request stream and response stream. Where only a single request or response
+ /// message is expected, you are responsible for enforcing this invariant is maintained.
+ ///
+ /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol``
+ /// or ``SimpleServiceProtocol`` instead.
+ internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
+ /// Handle the "GetFlag" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_GetFlagRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_GetFlagResponse` messages.
+ func getFlag(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+
+ /// Handle the "CreateFlag" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_CreateFlagRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_CreateFlagResponse` messages.
+ func createFlag(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+
+ /// Handle the "UpdateFlag" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_UpdateFlagRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_UpdateFlagResponse` messages.
+ func updateFlag(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+
+ /// Handle the "ListFlags" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_ListFlagsRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_ListFlagsResponse` messages.
+ func listFlags(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+
+ /// Handle the "DeleteFlag" method.
+ ///
+ /// - Parameters:
+ /// - request: A streaming request of `Oteldemo_DeleteFlagRequest` messages.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A streaming response of `Oteldemo_DeleteFlagResponse` messages.
+ func deleteFlag(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse
+ }
+
+ /// Service protocol for the "oteldemo.FeatureFlagService" service.
+ ///
+ /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than
+ /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and
+ /// trailing response metadata. If you don't need these then consider using
+ /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then
+ /// use ``StreamingServiceProtocol``.
+ internal protocol ServiceProtocol: Oteldemo_FeatureFlagService.StreamingServiceProtocol {
+ /// Handle the "GetFlag" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_GetFlagRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_GetFlagResponse` message.
+ func getFlag(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+
+ /// Handle the "CreateFlag" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_CreateFlagRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_CreateFlagResponse` message.
+ func createFlag(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+
+ /// Handle the "UpdateFlag" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_UpdateFlagRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_UpdateFlagResponse` message.
+ func updateFlag(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+
+ /// Handle the "ListFlags" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_ListFlagsRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_ListFlagsResponse` message.
+ func listFlags(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+
+ /// Handle the "DeleteFlag" method.
+ ///
+ /// - Parameters:
+ /// - request: A request containing a single `Oteldemo_DeleteFlagRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A response containing a single `Oteldemo_DeleteFlagResponse` message.
+ func deleteFlag(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse
+ }
+
+ /// Simple service protocol for the "oteldemo.FeatureFlagService" service.
+ ///
+ /// This is the highest level protocol for the service. The API is the easiest to use but
+ /// doesn't provide access to request or response metadata. If you need access to these
+ /// then use ``ServiceProtocol`` instead.
+ internal protocol SimpleServiceProtocol: Oteldemo_FeatureFlagService.ServiceProtocol {
+ /// Handle the "GetFlag" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_GetFlagRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_GetFlagResponse` to respond with.
+ func getFlag(
+ request: Oteldemo_GetFlagRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_GetFlagResponse
+
+ /// Handle the "CreateFlag" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_CreateFlagRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_CreateFlagResponse` to respond with.
+ func createFlag(
+ request: Oteldemo_CreateFlagRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_CreateFlagResponse
+
+ /// Handle the "UpdateFlag" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_UpdateFlagRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_UpdateFlagResponse` to respond with.
+ func updateFlag(
+ request: Oteldemo_UpdateFlagRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_UpdateFlagResponse
+
+ /// Handle the "ListFlags" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_ListFlagsRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_ListFlagsResponse` to respond with.
+ func listFlags(
+ request: Oteldemo_ListFlagsRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_ListFlagsResponse
+
+ /// Handle the "DeleteFlag" method.
+ ///
+ /// - Parameters:
+ /// - request: A `Oteldemo_DeleteFlagRequest` message.
+ /// - context: Context providing information about the RPC.
+ /// - Throws: Any error which occurred during the processing of the request. Thrown errors
+ /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
+ /// to an internal error.
+ /// - Returns: A `Oteldemo_DeleteFlagResponse` to respond with.
+ func deleteFlag(
+ request: Oteldemo_DeleteFlagRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> Oteldemo_DeleteFlagResponse
+ }
+}
+
+// Default implementation of 'registerMethods(with:)'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_FeatureFlagService.StreamingServiceProtocol {
+ internal func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport {
+ router.registerHandler(
+ forMethod: Oteldemo_FeatureFlagService.Method.GetFlag.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.getFlag(
+ request: request,
+ context: context
+ )
+ }
+ )
+ router.registerHandler(
+ forMethod: Oteldemo_FeatureFlagService.Method.CreateFlag.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.createFlag(
+ request: request,
+ context: context
+ )
+ }
+ )
+ router.registerHandler(
+ forMethod: Oteldemo_FeatureFlagService.Method.UpdateFlag.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.updateFlag(
+ request: request,
+ context: context
+ )
+ }
+ )
+ router.registerHandler(
+ forMethod: Oteldemo_FeatureFlagService.Method.ListFlags.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.listFlags(
+ request: request,
+ context: context
+ )
+ }
+ )
+ router.registerHandler(
+ forMethod: Oteldemo_FeatureFlagService.Method.DeleteFlag.descriptor,
+ deserializer: GRPCProtobuf.ProtobufDeserializer(),
+ serializer: GRPCProtobuf.ProtobufSerializer(),
+ handler: { request, context in
+ try await self.deleteFlag(
+ request: request,
+ context: context
+ )
+ }
+ )
+ }
+}
+
+// Default implementation of streaming methods from 'StreamingServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_FeatureFlagService.ServiceProtocol {
+ internal func getFlag(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.getFlag(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+
+ internal func createFlag(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.createFlag(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+
+ internal func updateFlag(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.updateFlag(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+
+ internal func listFlags(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.listFlags(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+
+ internal func deleteFlag(
+ request: GRPCCore.StreamingServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.StreamingServerResponse {
+ let response = try await self.deleteFlag(
+ request: GRPCCore.ServerRequest(stream: request),
+ context: context
+ )
+ return GRPCCore.StreamingServerResponse(single: response)
+ }
+}
+
+// Default implementation of methods from 'ServiceProtocol'.
+@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
+extension Oteldemo_FeatureFlagService.SimpleServiceProtocol {
+ internal func getFlag(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.getFlag(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+
+ internal func createFlag(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse {
+ return GRPCCore.ServerResponse(
+ message: try await self.createFlag(
+ request: request.message,
+ context: context
+ ),
+ metadata: [:]
+ )
+ }
+
+ internal func updateFlag(
+ request: GRPCCore.ServerRequest,
+ context: GRPCCore.ServerContext
+ ) async throws -> GRPCCore.ServerResponse