Initial commit of cart service using .net core 2.0. Working prototype without cache implementation (yet)

This commit is contained in:
Simon Zeltser 2018-06-20 15:40:07 -07:00
parent 2316e25504
commit 2df80b14c9
6 changed files with 6524 additions and 0 deletions

View file

@ -0,0 +1,120 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Grpc.Core;
using Hipstershop;
using static Hipstershop.CartService;
namespace cartservice
{
// Cart wrapper to deal with grpc communication
internal class CartServiceImpl : CartServiceBase
{
private CartStore cartStore;
public CartServiceImpl(CartStore cartStore)
{
this.cartStore = cartStore;
}
public override Task<Empty> AddItem(AddItemRequest request, Grpc.Core.ServerCallContext context)
{
cartStore.AddItem(request.UserId, request.Item.ProductId, request.Item.Quantity);
return Task.FromResult(new Empty());
}
public override Task<Empty> EmptyCart(EmptyCartRequest request, ServerCallContext context)
{
cartStore.EmptyCart(request.UserId);
return Task.FromResult(new Empty());
}
public override Task<Hipstershop.Cart> GetCart(GetCartRequest request, ServerCallContext context)
{
var cart = cartStore.GetCart(request.UserId);
return Task.FromResult(cart.ToHipsterCart());
}
}
internal class CartStore
{
// Maps between user and their cart
private ConcurrentDictionary<string, Cart> userCartItems = new ConcurrentDictionary<string, Cart>();
public void AddItem(string userId, string productId, int quantity)
{
Cart cart;
if (!userCartItems.TryGetValue(userId, out cart))
{
cart = new Cart(userId);
}
else
{
cart = userCartItems[userId];
}
cart.AddItem(productId, quantity);
}
public void EmptyCart(string userId)
{
Cart cart;
if (userCartItems.TryGetValue(userId, out cart))
{
cart.EmptyCart();
}
}
public Cart GetCart(string userId)
{
Cart cart = null;
userCartItems.TryGetValue(userId, out cart);
return cart;
}
}
internal static class CartUtils
{
public static Hipstershop.Cart ToHipsterCart(this Cart cart)
{
var hipsterCart = new Hipstershop.Cart
{
UserId = cart.UserId,
Items = { cart.Items.Select(i => new CartItem { ProductId = i.Key, Quantity = i.Value }) }
};
return hipsterCart;
}
}
// Actual implementation of the cart
internal class Cart
{
// Maps between productId and its quantity
private Dictionary<string, int> cart = new Dictionary<string, int>();
public Cart(string userId)
{
UserId = userId;
}
public string UserId { get; set; }
public void AddItem(string productId, int quantity)
{
cart.Add(productId, quantity);
}
public void EmptyCart()
{
cart.Clear();
}
public IReadOnlyDictionary<string, int> Items
{
get
{
return cart;
}
}
}
}

5394
src/cartservice/Demo.cs Normal file

File diff suppressed because it is too large Load diff

908
src/cartservice/DemoGrpc.cs Normal file
View file

@ -0,0 +1,908 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: demo.proto
// </auto-generated>
#pragma warning disable 1591
#region Designer generated code
using grpc = global::Grpc.Core;
namespace Hipstershop {
public static partial class CartService
{
static readonly string __ServiceName = "hipstershop.CartService";
static readonly grpc::Marshaller<global::Hipstershop.AddItemRequest> __Marshaller_AddItemRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.AddItemRequest.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.Empty> __Marshaller_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.Empty.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.GetCartRequest> __Marshaller_GetCartRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.GetCartRequest.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.Cart> __Marshaller_Cart = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.Cart.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.EmptyCartRequest> __Marshaller_EmptyCartRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.EmptyCartRequest.Parser.ParseFrom);
static readonly grpc::Method<global::Hipstershop.AddItemRequest, global::Hipstershop.Empty> __Method_AddItem = new grpc::Method<global::Hipstershop.AddItemRequest, global::Hipstershop.Empty>(
grpc::MethodType.Unary,
__ServiceName,
"AddItem",
__Marshaller_AddItemRequest,
__Marshaller_Empty);
static readonly grpc::Method<global::Hipstershop.GetCartRequest, global::Hipstershop.Cart> __Method_GetCart = new grpc::Method<global::Hipstershop.GetCartRequest, global::Hipstershop.Cart>(
grpc::MethodType.Unary,
__ServiceName,
"GetCart",
__Marshaller_GetCartRequest,
__Marshaller_Cart);
static readonly grpc::Method<global::Hipstershop.EmptyCartRequest, global::Hipstershop.Empty> __Method_EmptyCart = new grpc::Method<global::Hipstershop.EmptyCartRequest, global::Hipstershop.Empty>(
grpc::MethodType.Unary,
__ServiceName,
"EmptyCart",
__Marshaller_EmptyCartRequest,
__Marshaller_Empty);
/// <summary>Service descriptor</summary>
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{
get { return global::Hipstershop.DemoReflection.Descriptor.Services[0]; }
}
/// <summary>Base class for server-side implementations of CartService</summary>
public abstract partial class CartServiceBase
{
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.Empty> AddItem(global::Hipstershop.AddItemRequest request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.Cart> GetCart(global::Hipstershop.GetCartRequest request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.Empty> EmptyCart(global::Hipstershop.EmptyCartRequest request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
}
/// <summary>Client for CartService</summary>
public partial class CartServiceClient : grpc::ClientBase<CartServiceClient>
{
/// <summary>Creates a new client for CartService</summary>
/// <param name="channel">The channel to use to make remote calls.</param>
public CartServiceClient(grpc::Channel channel) : base(channel)
{
}
/// <summary>Creates a new client for CartService that uses a custom <c>CallInvoker</c>.</summary>
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
public CartServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker)
{
}
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
protected CartServiceClient() : base()
{
}
/// <summary>Protected constructor to allow creation of configured clients.</summary>
/// <param name="configuration">The client configuration.</param>
protected CartServiceClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
public virtual global::Hipstershop.Empty AddItem(global::Hipstershop.AddItemRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return AddItem(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.Empty AddItem(global::Hipstershop.AddItemRequest request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_AddItem, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.Empty> AddItemAsync(global::Hipstershop.AddItemRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return AddItemAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.Empty> AddItemAsync(global::Hipstershop.AddItemRequest request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_AddItem, null, options, request);
}
public virtual global::Hipstershop.Cart GetCart(global::Hipstershop.GetCartRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return GetCart(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.Cart GetCart(global::Hipstershop.GetCartRequest request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_GetCart, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.Cart> GetCartAsync(global::Hipstershop.GetCartRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return GetCartAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.Cart> GetCartAsync(global::Hipstershop.GetCartRequest request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_GetCart, null, options, request);
}
public virtual global::Hipstershop.Empty EmptyCart(global::Hipstershop.EmptyCartRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return EmptyCart(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.Empty EmptyCart(global::Hipstershop.EmptyCartRequest request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_EmptyCart, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.Empty> EmptyCartAsync(global::Hipstershop.EmptyCartRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return EmptyCartAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.Empty> EmptyCartAsync(global::Hipstershop.EmptyCartRequest request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_EmptyCart, null, options, request);
}
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
protected override CartServiceClient NewInstance(ClientBaseConfiguration configuration)
{
return new CartServiceClient(configuration);
}
}
/// <summary>Creates service definition that can be registered with a server</summary>
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static grpc::ServerServiceDefinition BindService(CartServiceBase serviceImpl)
{
return grpc::ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_AddItem, serviceImpl.AddItem)
.AddMethod(__Method_GetCart, serviceImpl.GetCart)
.AddMethod(__Method_EmptyCart, serviceImpl.EmptyCart).Build();
}
}
public static partial class RecommendationService
{
static readonly string __ServiceName = "hipstershop.RecommendationService";
static readonly grpc::Marshaller<global::Hipstershop.ListRecommendationsRequest> __Marshaller_ListRecommendationsRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.ListRecommendationsRequest.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.ListRecommendationsResponse> __Marshaller_ListRecommendationsResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.ListRecommendationsResponse.Parser.ParseFrom);
static readonly grpc::Method<global::Hipstershop.ListRecommendationsRequest, global::Hipstershop.ListRecommendationsResponse> __Method_ListRecommendations = new grpc::Method<global::Hipstershop.ListRecommendationsRequest, global::Hipstershop.ListRecommendationsResponse>(
grpc::MethodType.Unary,
__ServiceName,
"ListRecommendations",
__Marshaller_ListRecommendationsRequest,
__Marshaller_ListRecommendationsResponse);
/// <summary>Service descriptor</summary>
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{
get { return global::Hipstershop.DemoReflection.Descriptor.Services[1]; }
}
/// <summary>Base class for server-side implementations of RecommendationService</summary>
public abstract partial class RecommendationServiceBase
{
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.ListRecommendationsResponse> ListRecommendations(global::Hipstershop.ListRecommendationsRequest request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
}
/// <summary>Client for RecommendationService</summary>
public partial class RecommendationServiceClient : grpc::ClientBase<RecommendationServiceClient>
{
/// <summary>Creates a new client for RecommendationService</summary>
/// <param name="channel">The channel to use to make remote calls.</param>
public RecommendationServiceClient(grpc::Channel channel) : base(channel)
{
}
/// <summary>Creates a new client for RecommendationService that uses a custom <c>CallInvoker</c>.</summary>
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
public RecommendationServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker)
{
}
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
protected RecommendationServiceClient() : base()
{
}
/// <summary>Protected constructor to allow creation of configured clients.</summary>
/// <param name="configuration">The client configuration.</param>
protected RecommendationServiceClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
public virtual global::Hipstershop.ListRecommendationsResponse ListRecommendations(global::Hipstershop.ListRecommendationsRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return ListRecommendations(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.ListRecommendationsResponse ListRecommendations(global::Hipstershop.ListRecommendationsRequest request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_ListRecommendations, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.ListRecommendationsResponse> ListRecommendationsAsync(global::Hipstershop.ListRecommendationsRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return ListRecommendationsAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.ListRecommendationsResponse> ListRecommendationsAsync(global::Hipstershop.ListRecommendationsRequest request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_ListRecommendations, null, options, request);
}
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
protected override RecommendationServiceClient NewInstance(ClientBaseConfiguration configuration)
{
return new RecommendationServiceClient(configuration);
}
}
/// <summary>Creates service definition that can be registered with a server</summary>
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static grpc::ServerServiceDefinition BindService(RecommendationServiceBase serviceImpl)
{
return grpc::ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_ListRecommendations, serviceImpl.ListRecommendations).Build();
}
}
public static partial class ProductCatalogService
{
static readonly string __ServiceName = "hipstershop.ProductCatalogService";
static readonly grpc::Marshaller<global::Hipstershop.Empty> __Marshaller_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.Empty.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.ListProductsResponse> __Marshaller_ListProductsResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.ListProductsResponse.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.GetProductRequest> __Marshaller_GetProductRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.GetProductRequest.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.Product> __Marshaller_Product = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.Product.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.SearchProductsRequest> __Marshaller_SearchProductsRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.SearchProductsRequest.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.SearchProductsResponse> __Marshaller_SearchProductsResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.SearchProductsResponse.Parser.ParseFrom);
static readonly grpc::Method<global::Hipstershop.Empty, global::Hipstershop.ListProductsResponse> __Method_ListProducts = new grpc::Method<global::Hipstershop.Empty, global::Hipstershop.ListProductsResponse>(
grpc::MethodType.Unary,
__ServiceName,
"ListProducts",
__Marshaller_Empty,
__Marshaller_ListProductsResponse);
static readonly grpc::Method<global::Hipstershop.GetProductRequest, global::Hipstershop.Product> __Method_GetProduct = new grpc::Method<global::Hipstershop.GetProductRequest, global::Hipstershop.Product>(
grpc::MethodType.Unary,
__ServiceName,
"GetProduct",
__Marshaller_GetProductRequest,
__Marshaller_Product);
static readonly grpc::Method<global::Hipstershop.SearchProductsRequest, global::Hipstershop.SearchProductsResponse> __Method_SearchProducts = new grpc::Method<global::Hipstershop.SearchProductsRequest, global::Hipstershop.SearchProductsResponse>(
grpc::MethodType.Unary,
__ServiceName,
"SearchProducts",
__Marshaller_SearchProductsRequest,
__Marshaller_SearchProductsResponse);
/// <summary>Service descriptor</summary>
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{
get { return global::Hipstershop.DemoReflection.Descriptor.Services[2]; }
}
/// <summary>Base class for server-side implementations of ProductCatalogService</summary>
public abstract partial class ProductCatalogServiceBase
{
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.ListProductsResponse> ListProducts(global::Hipstershop.Empty request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.Product> GetProduct(global::Hipstershop.GetProductRequest request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.SearchProductsResponse> SearchProducts(global::Hipstershop.SearchProductsRequest request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
}
/// <summary>Client for ProductCatalogService</summary>
public partial class ProductCatalogServiceClient : grpc::ClientBase<ProductCatalogServiceClient>
{
/// <summary>Creates a new client for ProductCatalogService</summary>
/// <param name="channel">The channel to use to make remote calls.</param>
public ProductCatalogServiceClient(grpc::Channel channel) : base(channel)
{
}
/// <summary>Creates a new client for ProductCatalogService that uses a custom <c>CallInvoker</c>.</summary>
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
public ProductCatalogServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker)
{
}
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
protected ProductCatalogServiceClient() : base()
{
}
/// <summary>Protected constructor to allow creation of configured clients.</summary>
/// <param name="configuration">The client configuration.</param>
protected ProductCatalogServiceClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
public virtual global::Hipstershop.ListProductsResponse ListProducts(global::Hipstershop.Empty request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return ListProducts(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.ListProductsResponse ListProducts(global::Hipstershop.Empty request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_ListProducts, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.ListProductsResponse> ListProductsAsync(global::Hipstershop.Empty request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return ListProductsAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.ListProductsResponse> ListProductsAsync(global::Hipstershop.Empty request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_ListProducts, null, options, request);
}
public virtual global::Hipstershop.Product GetProduct(global::Hipstershop.GetProductRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return GetProduct(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.Product GetProduct(global::Hipstershop.GetProductRequest request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_GetProduct, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.Product> GetProductAsync(global::Hipstershop.GetProductRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return GetProductAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.Product> GetProductAsync(global::Hipstershop.GetProductRequest request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_GetProduct, null, options, request);
}
public virtual global::Hipstershop.SearchProductsResponse SearchProducts(global::Hipstershop.SearchProductsRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return SearchProducts(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.SearchProductsResponse SearchProducts(global::Hipstershop.SearchProductsRequest request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_SearchProducts, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.SearchProductsResponse> SearchProductsAsync(global::Hipstershop.SearchProductsRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return SearchProductsAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.SearchProductsResponse> SearchProductsAsync(global::Hipstershop.SearchProductsRequest request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_SearchProducts, null, options, request);
}
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
protected override ProductCatalogServiceClient NewInstance(ClientBaseConfiguration configuration)
{
return new ProductCatalogServiceClient(configuration);
}
}
/// <summary>Creates service definition that can be registered with a server</summary>
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static grpc::ServerServiceDefinition BindService(ProductCatalogServiceBase serviceImpl)
{
return grpc::ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_ListProducts, serviceImpl.ListProducts)
.AddMethod(__Method_GetProduct, serviceImpl.GetProduct)
.AddMethod(__Method_SearchProducts, serviceImpl.SearchProducts).Build();
}
}
public static partial class ShippingService
{
static readonly string __ServiceName = "hipstershop.ShippingService";
static readonly grpc::Marshaller<global::Hipstershop.GetQuoteRequest> __Marshaller_GetQuoteRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.GetQuoteRequest.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.GetQuoteResponse> __Marshaller_GetQuoteResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.GetQuoteResponse.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.ShipOrderRequest> __Marshaller_ShipOrderRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.ShipOrderRequest.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.ShipOrderResponse> __Marshaller_ShipOrderResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.ShipOrderResponse.Parser.ParseFrom);
static readonly grpc::Method<global::Hipstershop.GetQuoteRequest, global::Hipstershop.GetQuoteResponse> __Method_GetQuote = new grpc::Method<global::Hipstershop.GetQuoteRequest, global::Hipstershop.GetQuoteResponse>(
grpc::MethodType.Unary,
__ServiceName,
"GetQuote",
__Marshaller_GetQuoteRequest,
__Marshaller_GetQuoteResponse);
static readonly grpc::Method<global::Hipstershop.ShipOrderRequest, global::Hipstershop.ShipOrderResponse> __Method_ShipOrder = new grpc::Method<global::Hipstershop.ShipOrderRequest, global::Hipstershop.ShipOrderResponse>(
grpc::MethodType.Unary,
__ServiceName,
"ShipOrder",
__Marshaller_ShipOrderRequest,
__Marshaller_ShipOrderResponse);
/// <summary>Service descriptor</summary>
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{
get { return global::Hipstershop.DemoReflection.Descriptor.Services[3]; }
}
/// <summary>Base class for server-side implementations of ShippingService</summary>
public abstract partial class ShippingServiceBase
{
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.GetQuoteResponse> GetQuote(global::Hipstershop.GetQuoteRequest request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.ShipOrderResponse> ShipOrder(global::Hipstershop.ShipOrderRequest request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
}
/// <summary>Client for ShippingService</summary>
public partial class ShippingServiceClient : grpc::ClientBase<ShippingServiceClient>
{
/// <summary>Creates a new client for ShippingService</summary>
/// <param name="channel">The channel to use to make remote calls.</param>
public ShippingServiceClient(grpc::Channel channel) : base(channel)
{
}
/// <summary>Creates a new client for ShippingService that uses a custom <c>CallInvoker</c>.</summary>
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
public ShippingServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker)
{
}
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
protected ShippingServiceClient() : base()
{
}
/// <summary>Protected constructor to allow creation of configured clients.</summary>
/// <param name="configuration">The client configuration.</param>
protected ShippingServiceClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
public virtual global::Hipstershop.GetQuoteResponse GetQuote(global::Hipstershop.GetQuoteRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return GetQuote(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.GetQuoteResponse GetQuote(global::Hipstershop.GetQuoteRequest request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_GetQuote, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.GetQuoteResponse> GetQuoteAsync(global::Hipstershop.GetQuoteRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return GetQuoteAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.GetQuoteResponse> GetQuoteAsync(global::Hipstershop.GetQuoteRequest request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_GetQuote, null, options, request);
}
public virtual global::Hipstershop.ShipOrderResponse ShipOrder(global::Hipstershop.ShipOrderRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return ShipOrder(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.ShipOrderResponse ShipOrder(global::Hipstershop.ShipOrderRequest request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_ShipOrder, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.ShipOrderResponse> ShipOrderAsync(global::Hipstershop.ShipOrderRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return ShipOrderAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.ShipOrderResponse> ShipOrderAsync(global::Hipstershop.ShipOrderRequest request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_ShipOrder, null, options, request);
}
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
protected override ShippingServiceClient NewInstance(ClientBaseConfiguration configuration)
{
return new ShippingServiceClient(configuration);
}
}
/// <summary>Creates service definition that can be registered with a server</summary>
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static grpc::ServerServiceDefinition BindService(ShippingServiceBase serviceImpl)
{
return grpc::ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_GetQuote, serviceImpl.GetQuote)
.AddMethod(__Method_ShipOrder, serviceImpl.ShipOrder).Build();
}
}
public static partial class CurrencyService
{
static readonly string __ServiceName = "hipstershop.CurrencyService";
static readonly grpc::Marshaller<global::Hipstershop.Empty> __Marshaller_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.Empty.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.GetSupportedCurrenciesResponse> __Marshaller_GetSupportedCurrenciesResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.GetSupportedCurrenciesResponse.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.ConversionRequest> __Marshaller_ConversionRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.ConversionRequest.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.ConversionResponse> __Marshaller_ConversionResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.ConversionResponse.Parser.ParseFrom);
static readonly grpc::Method<global::Hipstershop.Empty, global::Hipstershop.GetSupportedCurrenciesResponse> __Method_GetSupportedCurrencies = new grpc::Method<global::Hipstershop.Empty, global::Hipstershop.GetSupportedCurrenciesResponse>(
grpc::MethodType.Unary,
__ServiceName,
"GetSupportedCurrencies",
__Marshaller_Empty,
__Marshaller_GetSupportedCurrenciesResponse);
static readonly grpc::Method<global::Hipstershop.ConversionRequest, global::Hipstershop.ConversionResponse> __Method_Convert = new grpc::Method<global::Hipstershop.ConversionRequest, global::Hipstershop.ConversionResponse>(
grpc::MethodType.Unary,
__ServiceName,
"Convert",
__Marshaller_ConversionRequest,
__Marshaller_ConversionResponse);
/// <summary>Service descriptor</summary>
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{
get { return global::Hipstershop.DemoReflection.Descriptor.Services[4]; }
}
/// <summary>Base class for server-side implementations of CurrencyService</summary>
public abstract partial class CurrencyServiceBase
{
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.GetSupportedCurrenciesResponse> GetSupportedCurrencies(global::Hipstershop.Empty request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.ConversionResponse> Convert(global::Hipstershop.ConversionRequest request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
}
/// <summary>Client for CurrencyService</summary>
public partial class CurrencyServiceClient : grpc::ClientBase<CurrencyServiceClient>
{
/// <summary>Creates a new client for CurrencyService</summary>
/// <param name="channel">The channel to use to make remote calls.</param>
public CurrencyServiceClient(grpc::Channel channel) : base(channel)
{
}
/// <summary>Creates a new client for CurrencyService that uses a custom <c>CallInvoker</c>.</summary>
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
public CurrencyServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker)
{
}
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
protected CurrencyServiceClient() : base()
{
}
/// <summary>Protected constructor to allow creation of configured clients.</summary>
/// <param name="configuration">The client configuration.</param>
protected CurrencyServiceClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
public virtual global::Hipstershop.GetSupportedCurrenciesResponse GetSupportedCurrencies(global::Hipstershop.Empty request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return GetSupportedCurrencies(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.GetSupportedCurrenciesResponse GetSupportedCurrencies(global::Hipstershop.Empty request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_GetSupportedCurrencies, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.GetSupportedCurrenciesResponse> GetSupportedCurrenciesAsync(global::Hipstershop.Empty request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return GetSupportedCurrenciesAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.GetSupportedCurrenciesResponse> GetSupportedCurrenciesAsync(global::Hipstershop.Empty request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_GetSupportedCurrencies, null, options, request);
}
public virtual global::Hipstershop.ConversionResponse Convert(global::Hipstershop.ConversionRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return Convert(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.ConversionResponse Convert(global::Hipstershop.ConversionRequest request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_Convert, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.ConversionResponse> ConvertAsync(global::Hipstershop.ConversionRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return ConvertAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.ConversionResponse> ConvertAsync(global::Hipstershop.ConversionRequest request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_Convert, null, options, request);
}
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
protected override CurrencyServiceClient NewInstance(ClientBaseConfiguration configuration)
{
return new CurrencyServiceClient(configuration);
}
}
/// <summary>Creates service definition that can be registered with a server</summary>
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static grpc::ServerServiceDefinition BindService(CurrencyServiceBase serviceImpl)
{
return grpc::ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_GetSupportedCurrencies, serviceImpl.GetSupportedCurrencies)
.AddMethod(__Method_Convert, serviceImpl.Convert).Build();
}
}
public static partial class PaymentService
{
static readonly string __ServiceName = "hipstershop.PaymentService";
static readonly grpc::Marshaller<global::Hipstershop.ChargeRequest> __Marshaller_ChargeRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.ChargeRequest.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.ChargeResponse> __Marshaller_ChargeResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.ChargeResponse.Parser.ParseFrom);
static readonly grpc::Method<global::Hipstershop.ChargeRequest, global::Hipstershop.ChargeResponse> __Method_Charge = new grpc::Method<global::Hipstershop.ChargeRequest, global::Hipstershop.ChargeResponse>(
grpc::MethodType.Unary,
__ServiceName,
"Charge",
__Marshaller_ChargeRequest,
__Marshaller_ChargeResponse);
/// <summary>Service descriptor</summary>
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{
get { return global::Hipstershop.DemoReflection.Descriptor.Services[5]; }
}
/// <summary>Base class for server-side implementations of PaymentService</summary>
public abstract partial class PaymentServiceBase
{
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.ChargeResponse> Charge(global::Hipstershop.ChargeRequest request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
}
/// <summary>Client for PaymentService</summary>
public partial class PaymentServiceClient : grpc::ClientBase<PaymentServiceClient>
{
/// <summary>Creates a new client for PaymentService</summary>
/// <param name="channel">The channel to use to make remote calls.</param>
public PaymentServiceClient(grpc::Channel channel) : base(channel)
{
}
/// <summary>Creates a new client for PaymentService that uses a custom <c>CallInvoker</c>.</summary>
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
public PaymentServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker)
{
}
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
protected PaymentServiceClient() : base()
{
}
/// <summary>Protected constructor to allow creation of configured clients.</summary>
/// <param name="configuration">The client configuration.</param>
protected PaymentServiceClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
public virtual global::Hipstershop.ChargeResponse Charge(global::Hipstershop.ChargeRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return Charge(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.ChargeResponse Charge(global::Hipstershop.ChargeRequest request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_Charge, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.ChargeResponse> ChargeAsync(global::Hipstershop.ChargeRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return ChargeAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.ChargeResponse> ChargeAsync(global::Hipstershop.ChargeRequest request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_Charge, null, options, request);
}
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
protected override PaymentServiceClient NewInstance(ClientBaseConfiguration configuration)
{
return new PaymentServiceClient(configuration);
}
}
/// <summary>Creates service definition that can be registered with a server</summary>
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static grpc::ServerServiceDefinition BindService(PaymentServiceBase serviceImpl)
{
return grpc::ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_Charge, serviceImpl.Charge).Build();
}
}
public static partial class EmailService
{
static readonly string __ServiceName = "hipstershop.EmailService";
static readonly grpc::Marshaller<global::Hipstershop.SendOrderConfirmationRequest> __Marshaller_SendOrderConfirmationRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.SendOrderConfirmationRequest.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.Empty> __Marshaller_Empty = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.Empty.Parser.ParseFrom);
static readonly grpc::Method<global::Hipstershop.SendOrderConfirmationRequest, global::Hipstershop.Empty> __Method_SendOrderConfirmation = new grpc::Method<global::Hipstershop.SendOrderConfirmationRequest, global::Hipstershop.Empty>(
grpc::MethodType.Unary,
__ServiceName,
"SendOrderConfirmation",
__Marshaller_SendOrderConfirmationRequest,
__Marshaller_Empty);
/// <summary>Service descriptor</summary>
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{
get { return global::Hipstershop.DemoReflection.Descriptor.Services[6]; }
}
/// <summary>Base class for server-side implementations of EmailService</summary>
public abstract partial class EmailServiceBase
{
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.Empty> SendOrderConfirmation(global::Hipstershop.SendOrderConfirmationRequest request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
}
/// <summary>Client for EmailService</summary>
public partial class EmailServiceClient : grpc::ClientBase<EmailServiceClient>
{
/// <summary>Creates a new client for EmailService</summary>
/// <param name="channel">The channel to use to make remote calls.</param>
public EmailServiceClient(grpc::Channel channel) : base(channel)
{
}
/// <summary>Creates a new client for EmailService that uses a custom <c>CallInvoker</c>.</summary>
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
public EmailServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker)
{
}
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
protected EmailServiceClient() : base()
{
}
/// <summary>Protected constructor to allow creation of configured clients.</summary>
/// <param name="configuration">The client configuration.</param>
protected EmailServiceClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
public virtual global::Hipstershop.Empty SendOrderConfirmation(global::Hipstershop.SendOrderConfirmationRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return SendOrderConfirmation(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.Empty SendOrderConfirmation(global::Hipstershop.SendOrderConfirmationRequest request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_SendOrderConfirmation, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.Empty> SendOrderConfirmationAsync(global::Hipstershop.SendOrderConfirmationRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return SendOrderConfirmationAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.Empty> SendOrderConfirmationAsync(global::Hipstershop.SendOrderConfirmationRequest request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_SendOrderConfirmation, null, options, request);
}
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
protected override EmailServiceClient NewInstance(ClientBaseConfiguration configuration)
{
return new EmailServiceClient(configuration);
}
}
/// <summary>Creates service definition that can be registered with a server</summary>
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static grpc::ServerServiceDefinition BindService(EmailServiceBase serviceImpl)
{
return grpc::ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_SendOrderConfirmation, serviceImpl.SendOrderConfirmation).Build();
}
}
public static partial class CheckoutService
{
static readonly string __ServiceName = "hipstershop.CheckoutService";
static readonly grpc::Marshaller<global::Hipstershop.CreateOrderRequest> __Marshaller_CreateOrderRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.CreateOrderRequest.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.CreateOrderResponse> __Marshaller_CreateOrderResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.CreateOrderResponse.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.PlaceOrderRequest> __Marshaller_PlaceOrderRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.PlaceOrderRequest.Parser.ParseFrom);
static readonly grpc::Marshaller<global::Hipstershop.PlaceOrderResponse> __Marshaller_PlaceOrderResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Hipstershop.PlaceOrderResponse.Parser.ParseFrom);
static readonly grpc::Method<global::Hipstershop.CreateOrderRequest, global::Hipstershop.CreateOrderResponse> __Method_CreateOrder = new grpc::Method<global::Hipstershop.CreateOrderRequest, global::Hipstershop.CreateOrderResponse>(
grpc::MethodType.Unary,
__ServiceName,
"CreateOrder",
__Marshaller_CreateOrderRequest,
__Marshaller_CreateOrderResponse);
static readonly grpc::Method<global::Hipstershop.PlaceOrderRequest, global::Hipstershop.PlaceOrderResponse> __Method_PlaceOrder = new grpc::Method<global::Hipstershop.PlaceOrderRequest, global::Hipstershop.PlaceOrderResponse>(
grpc::MethodType.Unary,
__ServiceName,
"PlaceOrder",
__Marshaller_PlaceOrderRequest,
__Marshaller_PlaceOrderResponse);
/// <summary>Service descriptor</summary>
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{
get { return global::Hipstershop.DemoReflection.Descriptor.Services[7]; }
}
/// <summary>Base class for server-side implementations of CheckoutService</summary>
public abstract partial class CheckoutServiceBase
{
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.CreateOrderResponse> CreateOrder(global::Hipstershop.CreateOrderRequest request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
public virtual global::System.Threading.Tasks.Task<global::Hipstershop.PlaceOrderResponse> PlaceOrder(global::Hipstershop.PlaceOrderRequest request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
}
/// <summary>Client for CheckoutService</summary>
public partial class CheckoutServiceClient : grpc::ClientBase<CheckoutServiceClient>
{
/// <summary>Creates a new client for CheckoutService</summary>
/// <param name="channel">The channel to use to make remote calls.</param>
public CheckoutServiceClient(grpc::Channel channel) : base(channel)
{
}
/// <summary>Creates a new client for CheckoutService that uses a custom <c>CallInvoker</c>.</summary>
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
public CheckoutServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker)
{
}
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
protected CheckoutServiceClient() : base()
{
}
/// <summary>Protected constructor to allow creation of configured clients.</summary>
/// <param name="configuration">The client configuration.</param>
protected CheckoutServiceClient(ClientBaseConfiguration configuration) : base(configuration)
{
}
public virtual global::Hipstershop.CreateOrderResponse CreateOrder(global::Hipstershop.CreateOrderRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return CreateOrder(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.CreateOrderResponse CreateOrder(global::Hipstershop.CreateOrderRequest request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_CreateOrder, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.CreateOrderResponse> CreateOrderAsync(global::Hipstershop.CreateOrderRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return CreateOrderAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.CreateOrderResponse> CreateOrderAsync(global::Hipstershop.CreateOrderRequest request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_CreateOrder, null, options, request);
}
public virtual global::Hipstershop.PlaceOrderResponse PlaceOrder(global::Hipstershop.PlaceOrderRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return PlaceOrder(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Hipstershop.PlaceOrderResponse PlaceOrder(global::Hipstershop.PlaceOrderRequest request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_PlaceOrder, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.PlaceOrderResponse> PlaceOrderAsync(global::Hipstershop.PlaceOrderRequest request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return PlaceOrderAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Hipstershop.PlaceOrderResponse> PlaceOrderAsync(global::Hipstershop.PlaceOrderRequest request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_PlaceOrder, null, options, request);
}
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
protected override CheckoutServiceClient NewInstance(ClientBaseConfiguration configuration)
{
return new CheckoutServiceClient(configuration);
}
}
/// <summary>Creates service definition that can be registered with a server</summary>
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static grpc::ServerServiceDefinition BindService(CheckoutServiceBase serviceImpl)
{
return grpc::ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_CreateOrder, serviceImpl.CreateOrder)
.AddMethod(__Method_PlaceOrder, serviceImpl.PlaceOrder).Build();
}
}
}
#endregion

View file

@ -0,0 +1,59 @@
using System;
using CommandLine;
using Grpc.Core;
namespace cartservice
{
class Program
{
[Verb("start", HelpText = "Starts the server listening on provided port")]
class ServerOptions
{
[Option('p', "port", HelpText = "The port on for running the server", Required = true)]
public int Port { get; set; }
}
static object StartServer(string host, int port)
{
var store = new CartStore();
Server server = new Server
{
Services = { Hipstershop.CartService.BindService(new CartServiceImpl(store)) },
Ports = { new ServerPort(host, port, ServerCredentials.Insecure) }
};
Console.WriteLine("Cart server is listening on port " + port);
Console.WriteLine("Press any key to stop the server...");
server.Start();
Console.ReadKey();
server.ShutdownAsync().Wait();
return null;
}
static void Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("Invalid number of arguments supplied");
Environment.Exit(-1);
}
switch (args[0])
{
case "start":
Parser.Default.ParseArguments<ServerOptions>(args).MapResult(
(ServerOptions options) => StartServer("localhost", options.Port),
errs => 1);
break;
default:
Console.WriteLine("Invalid command");
break;
}
Console.WriteLine("Hello World!");
}
}
}

View file

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.2.1" />
<PackageReference Include="Google.Protobuf" Version="3.5.1" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.5.1" />
<PackageReference Include="grpc" Version="1.12.0" />
<PackageReference Include="grpc.tools" Version="1.12.0" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,27 @@
@rem Copyright 2018 gRPC authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem Generate the C# code for .proto files
setlocal
@rem enter this directory
cd /d %~dp0
set NUGET_PATH=%UserProfile%\.nuget\packages
set TOOLS_PATH=%NUGET_PATH%\Grpc.Tools\1.12.0\tools\windows_x64
%TOOLS_PATH%\protoc.exe -I%~dp0/../../pb;%NUGET_PATH%\google.protobuf.tools\3.5.1\tools\ --csharp_out %~dp0 %~dp0\..\..\pb\demo.proto --grpc_out %~dp0 --plugin=protoc-gen-grpc=%TOOLS_PATH%\grpc_csharp_plugin.exe
endlocal