예제 #1
0
        private static async Task Main()
        {
            Console.Title = "Update Configuration";

            IDistributedSearchConfiguration demoCredential = new DemoCredential();

            var businessDataUpdates = new BusinessDataPump <FashionBusinessData, FashionBusinessDataUpdate>(
                demoCredential: demoCredential,
                createEmptyBusinessData: newFashionBusinessData,
                applyUpdate: FashionBusinessDataExtensions.ApplyFashionUpdate,
                snapshotContainerClient: new BlobContainerClient(
                    blobContainerUri: new Uri($"https://{demoCredential.BusinessDataSnapshotAccountName}.blob.core.windows.net/{demoCredential.BusinessDataSnapshotContainerName}/"),
                    credential: demoCredential.AADServicePrincipal));

            while (true)
            {
                await Console.Out.WriteAsync($"Please enter an item and a price, separated by a space: ");

                var input = await Console.In.ReadLineAsync();

                var values = input.Split(" ");
                if (values.Length != 2)
                {
                    continue;
                }
                var item = values[0];

                if (!decimal.TryParse(values[1], out var newMarkup))
                {
                    continue;
                }

                var update = FashionBusinessDataUpdate.NewMarkupUpdate(
                    fashionType: item,
                    markupPrice: newMarkup);

                // Here, we're directly dropping the update in Kafka.
                // This must be replaced with a secured HTTP request.
                var watermark = await businessDataUpdates.SendUpdate(update);

                await Console.Out.WriteLineAsync($"Update sent for {newMarkup} (#{watermark.Item})");
            }
        }
예제 #2
0
        public async Task <(Watermark, FashionBusinessData)> Post(FashionBusinessDataUpdate bdu)
        {
            await Task.Delay(TimeSpan.FromSeconds(1));

            return(Watermark.NewWatermark(-1), null);
        }