예제 #1
0
        public async Task ProcessAsync(IDispatchTarget target, NamespacedName key, ReconcileData data, CancellationToken cancellationToken)
        {
            try
            {
                var message = new Message
                {
                    MessageType = MessageType.Update,
                    Key         = $"{key.Namespace}:{key.Name}"
                };
                var context = new YarpIngressContext(data.Ingress, data.ServiceList, data.EndpointsList);
                YarpParser.CovertFromKubernetesIngress(context);

                message.Cluster = context.Clusters;
                message.Routes  = context.Routes;

                var bytes = JsonSerializer.SerializeToUtf8Bytes(message);

                _logger.LogInformation(JsonSerializer.Serialize(message));

                await _dispatcher.SendAsync(target, bytes, cancellationToken).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                _logger.LogWarning(ex.Message);
                throw;
            }
        }
예제 #2
0
        public async Task ParsingTests(string name)
        {
            var(ingress, endpoints) = await GetKubernetesInfo(name).ConfigureAwait(false);

            var context = new YarpIngressContext(ingress, endpoints);

            YarpParser.CovertFromKubernetesIngress(context);

            VerifyClusters(JsonSerializer.Serialize(context.Clusters), name);
            VerifyRoutes(JsonSerializer.Serialize(context.Routes), name);
        }