由丰鲁成发起的CORE SDK自动发布, BUILD_ID=186, 版本号:1.2.9

Signed-off-by: haowei.yao <haowei.yao@alibaba-inc.com>
This commit is contained in:
haowei.yao
2018-03-14 14:39:25 +08:00
parent 6b7af1732d
commit 89523ed659
16 changed files with 215 additions and 95 deletions

View File

@@ -18,13 +18,13 @@
#define ALIBABACLOUD_CORE_COMMONCLIENT_H_
#include <future>
#include "AsyncCallerContext.h"
#include "ClientConfiguration.h"
#include "CoreExport.h"
#include "CoreClient.h"
#include "CredentialsProvider.h"
#include "EndpointProvider.h"
#include "CommonRequest.h"
#include "CommonResponse.h"
#include "CredentialsProvider.h"
namespace AlibabaCloud
{
@@ -50,7 +50,6 @@ namespace AlibabaCloud
HttpRequest buildHttpRequest(const std::string & endpoint, const CommonRequest &msg, HttpRequest::Method method) const;
HttpRequest buildRoaHttpRequest(const std::string & endpoint, const CommonRequest &msg, HttpRequest::Method method) const;
HttpRequest buildRpcHttpRequest(const std::string & endpoint, const CommonRequest &msg, HttpRequest::Method method) const;
virtual EndpointOutcome endpoint() const override;
JsonOutcome makeRequest(const std::string &endpoint, const CommonRequest &msg, HttpRequest::Method method = HttpRequest::Method::Get)const;
private:
@@ -58,7 +57,6 @@ namespace AlibabaCloud
std::string canonicalizedHeaders(const HttpMessage::HeaderCollection &headers)const;
std::shared_ptr<CredentialsProvider> credentialsProvider_;
std::shared_ptr<EndpointProvider> endpointProvider_;
std::shared_ptr<Signer> signer_;
};
}

View File

@@ -33,20 +33,19 @@ namespace AlibabaCloud
class ALIBABACLOUD_CORE_EXPORT CoreClient
{
public:
CoreClient(const ClientConfiguration &configuration);
CoreClient(const std::string & servicename, const ClientConfiguration &configuration);
virtual ~CoreClient();
ClientConfiguration configuration()const;
std::string serviceName()const;
protected:
typedef Outcome<Error, std::string> EndpointOutcome;
HttpClient::HttpResponseOutcome AttemptRequest(const std::string & endpoint, const ServiceRequest &request, HttpRequest::Method method)const;
Error buildCoreError(const HttpResponse &response)const;
bool hasResponseError(const HttpResponse &response)const;
virtual HttpRequest buildHttpRequest(const std::string & endpoint, const ServiceRequest &msg, HttpRequest::Method method)const = 0;
void asyncExecute(Runnable * r)const;
virtual EndpointOutcome endpoint()const = 0;
private:
std::string serviceName_;
ClientConfiguration configuration_;
std::shared_ptr<CredentialsProvider> credentialsProvider_;
HttpClient *httpClient_;

View File

@@ -19,25 +19,42 @@
#include <string>
#include <chrono>
#include <list>
#include <map>
#include <mutex>
#include <alibabacloud/core/location/LocationClient.h>
#include <alibabacloud/core/CoreClient.h>
namespace AlibabaCloud
{
class ALIBABACLOUD_CORE_EXPORT EndpointProvider
{
public:
typedef Outcome<Error, std::string> EndpointOutcome;
EndpointProvider(const std::shared_ptr<Location::LocationClient>& locationClient,
const std::string regionId,
const std::string serviceCode,
const std::string product,
const std::string serviceCode = std::string(),
int durationSeconds = 3600);
~EndpointProvider();
std::string getEndpoint();
EndpointOutcome getEndpoint();
private:
void loadEndpoint();
struct Product
{
std::string code;
std::string locationServiceCode;
std::string documentId;
std::map<std::string, std::string> regionalEndpoints;
std::string globalEndpoint;
std::string regionalEndpointPattern;
};
EndpointOutcome loadRemoteEndpoint();
bool checkExpiry()const;
bool loadInternalProductsInfo();
std::string internalEndpoint(const std::string regionId, const std::string product);
std::mutex cachedMutex_;
std::string cachedEndpoint_;
@@ -45,7 +62,9 @@ namespace AlibabaCloud
int durationSeconds_;
std::chrono::system_clock::time_point expiry_;
std::string regionId_;
std::string product_;
std::string serviceCode_;
std::list<Product> internalProductsInfo_;
};
}
#endif

View File

@@ -34,7 +34,7 @@ namespace AlibabaCloud
public:
typedef Outcome<Error, std::string> JsonOutcome;
RoaServiceClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider,
RoaServiceClient(const std::string & servicename, const std::shared_ptr<CredentialsProvider> &credentialsProvider,
const ClientConfiguration &configuration,
const std::shared_ptr<Signer> &signer = std::make_shared<HmacSha1Signer>());
virtual ~RoaServiceClient();

View File

@@ -36,7 +36,7 @@ namespace AlibabaCloud
public:
typedef Outcome<Error, std::string> JsonOutcome;
RpcServiceClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider,
RpcServiceClient(const std::string & servicename, const std::shared_ptr<CredentialsProvider> &credentialsProvider,
const ClientConfiguration &configuration,
const std::shared_ptr<Signer> &signer = std::make_shared<HmacSha1Signer>());
virtual ~RpcServiceClient();

View File

@@ -42,8 +42,6 @@ namespace AlibabaCloud
DescribeEndpointsOutcome describeEndpoints(const Model::DescribeEndpointsRequest &request)const;
void describeEndpointsAsync(const Model::DescribeEndpointsRequest& request, const DescribeEndpointsAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
DescribeEndpointsOutcomeCallable describeEndpointsCallable(const Model::DescribeEndpointsRequest& request) const;
private:
virtual EndpointOutcome endpoint()const override;
};
}
}

View File

@@ -51,8 +51,6 @@ namespace AlibabaCloud
GetCallerIdentityOutcome getCallerIdentity(const Model::GetCallerIdentityRequest &request)const;
void getCallerIdentityAsync(const Model::GetCallerIdentityRequest& request, const GetCallerIdentityAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
GetCallerIdentityOutcomeCallable getCallerIdentityCallable(const Model::GetCallerIdentityRequest& request) const;
private:
virtual EndpointOutcome endpoint()const override;
};
}
}