private Uri AssembleLongPollRefreshUrl(string uri, string appId, string cluster, string?dataCenter)
    {
        if (!uri.EndsWith("/", StringComparison.Ordinal))
        {
            uri += "/";
        }

        var uriBuilder = new UriBuilder(uri + "notifications/v2");
        var query      = new Dictionary <string, string>();

        query["appId"]         = appId;
        query["cluster"]       = cluster;
        query["notifications"] = AssembleNotifications(_notifications);

        if (!string.IsNullOrEmpty(dataCenter))
        {
            query["dataCenter"] = dataCenter !;
        }
        var localIp = _options.LocalIp;

        if (!string.IsNullOrEmpty(localIp))
        {
            query["ip"] = localIp;
        }

        uriBuilder.Query = QueryUtils.Build(query);

        return(uriBuilder.Uri);
    }
예제 #2
0
        private string AssembleMetaServiceUrl()
        {
            var domainName = _options.MetaServer;
            var appId      = _options.AppId;
            var localIp    = _options.LocalIp;

            var uriBuilder = new UriBuilder(domainName + "/services/config");
            var query      = new Dictionary <string, string>();

            query["appId"] = appId;
            if (!string.IsNullOrEmpty(localIp))
            {
                query["ip"] = localIp;
            }

            uriBuilder.Query = QueryUtils.Build(query);

            return(uriBuilder.ToString());
        }
예제 #3
0
        private string AssembleQueryConfigUrl(string uri,
                                              string appId,
                                              string cluster,
                                              string?namespaceName,
                                              string?dataCenter,
                                              ApolloNotificationMessages remoteMessages,
                                              ApolloConfig previousConfig)
        {
            if (!uri.EndsWith("/", StringComparison.Ordinal))
            {
                uri += "/";
            }
            //Looks like .Net will handle all the url encoding for me...
            var path       = $"configs/{appId}/{cluster}/{namespaceName}";
            var uriBuilder = new UriBuilder(uri + path);
            var query      = new Dictionary <string, string>();

            if (previousConfig != null)
            {
                query["releaseKey"] = previousConfig.ReleaseKey;
            }

            if (!string.IsNullOrEmpty(dataCenter))
            {
                query["dataCenter"] = dataCenter !;
            }

            var localIp = _options.LocalIp;

            if (!string.IsNullOrEmpty(localIp))
            {
                query["ip"] = localIp;
            }

            if (remoteMessages != null)
            {
                query["messages"] = JsonConvert.SerializeObject(remoteMessages, JsonSettings);
            }

            uriBuilder.Query = QueryUtils.Build(query);

            return(uriBuilder.ToString());
        }