예제 #1
0
 private async Task<EndpointResponseModel> GetEndpointModel(string fabricAddress)
 {
     var endpoints = await GetInstanceEndpoints(fabricAddress);
     var endpointResult = new EndpointResponseModel
     {
         FabricAddress = fabricAddress,
         IsSuccess = true,
         AllInternalEndpoints = endpoints,
         InternalEndpointRandom = endpoints.OrderBy(x => Guid.NewGuid()).First(), //Todo: optimize this, endure even distribution
         IsRoutableByGateway = endpoints.Any(x => x.ToLower().Contains("http")),
         //Todo: get the port from config. 
         RoutedEndpoint = fabricAddress.ToString().Replace("fabric:/", "http://blankycluster.westus.cloudapp.azure.com/route/")
     };
     return endpointResult;
 }
예제 #2
0
        public async Task<List<EndpointResponseModel>> ListServiceEndpoints()
        {
            var servicesWithEndpoints = new List<EndpointResponseModel>();
            foreach (var service in await DiscoverClusterServices())
            {
                EndpointResponseModel endpointResult;
                if (service.IsStatefulService)
                {
                    endpointResult = new EndpointResponseModel
                    {
                        FabricAddress = service.FabricAddress.ToString(),
                        IsSuccess = false,
                        ErrorDetails = "StatefulService - Need Partition To Determine Endpoint"
                    };
                }
                else
                {
                    try
                    {
                        endpointResult = await GetEndpointModel(service.FabricAddress.ToString());
                    }
                    catch (Exception ex)
                    {
                        logger.LogWarning("Failed to get endpoint for stateless service", ex);
                        endpointResult = new EndpointResponseModel
                        {
                            IsSuccess = false,
                            ErrorDetails = ex.Message
                        };
                    }
                }

                servicesWithEndpoints.Add(endpointResult);
            }

            return servicesWithEndpoints;
        }