lukaszzborek commented on code in PR #2178: URL: https://github.com/apache/iggy/pull/2178#discussion_r2360891586
########## examples/csharp/src/Basic/Iggy_SDK.Examples.Basic.Consumer/Program.cs: ########## @@ -0,0 +1,92 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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. + +using System.Text; +using Apache.Iggy; +using Apache.Iggy.Factory; +using Apache.Iggy.Kinds; +using Iggy_SDK.Examples.Basic.Consumer; +using Iggy_SDK.Examples.Shared; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; + +var loggerFactory = LoggerFactory.Create(b => { b.AddConsole(); }); +var logger = loggerFactory.CreateLogger<Program>(); + +var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); +var settings = configuration.Get<Settings>() ?? new Settings(); + +logger.LogInformation( + "Basic consumer has started, selected protocol: {Protocol}", + settings.Protocol +); + +var client = MessageStreamFactory.CreateMessageStream( + opt => + { + opt.BaseAdress = settings.BaseAddress; + opt.Protocol = settings.Protocol; + }, + loggerFactory +); + +await client.LoginUser(settings.Username, settings.Password); + +logger.LogInformation("Basic consumer has logged on successfully"); + +var streamId = Identifier.String(settings.StreamName); +var topicId = Identifier.String(settings.TopicName); +var partitionId = 1u; +var consumerId = 1; + +await ExampleHelpers.EnsureStreamExists(client, streamId, settings.StreamName); +await ExampleHelpers.EnsureTopicExists( + client, + streamId, + topicId, + settings.TopicName, + settings.PartitionsCount +); + +var consumedBatches = 0; +while (true) Review Comment: we can show it, but i'm currently also working on better consumer/publisher client (also with builders) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
