Skip to content

Commit

Permalink
Fixing review changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dinusha92 committed Jun 15, 2018
1 parent a5f5dd9 commit 1034d30
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ function generateRequestEvent(http:Request request, http:FilterContext context)
requestStream.applicationOwner = authContext.subscriber;
requestStream.tier = authContext.tier;
requestStream.continuedOnThrottleOut = !authContext.stopOnQuotaReach;
requestStream.apiPublisher = authContext.apiPublisher;
requestStream.keyType = authContext.keyType;
}
requestStream.userAgent = request.userAgent;
requestStream.clientIp = getClientIp(request);
Expand All @@ -67,14 +69,11 @@ function generateRequestEvent(http:Request request, http:FilterContext context)

//todo: hostname verify
requestStream.hostName = "localhost"; //todo:get the host properl
//todo:check if apiPublisher comes in keyValidation context
requestStream.apiPublisher = "[email protected]"; //todo:get publisher properly
requestStream.method = request.method;
//todo:verify resourcepath and resourceTemplate
requestStream.resourceTemplate = "resourcePath";
requestStream.resourcePath = getResourceConfigAnnotation
(reflect:getResourceAnnotations(context.serviceType, context.resourceName)).path;
requestStream.keyType = "PRODUCTION";
//todo:random uuid taken from throttle filter
requestStream.correlationID = "71c60dbd-b2be-408d-9e2e-4fd11f60cfbc";
requestStream.requestCount = 1;
Expand Down Expand Up @@ -106,18 +105,18 @@ function getEventData(EventDTO dto) returns string {
function writeEventToFile(EventDTO eventDTO) {
//todo:batch events to reduce IO cost
int currentTime = getCurrentTime();
if (initializingTime == 0 ) {
if (initializingTime == 0) {
initializingTime = getCurrentTime();
}
if ( currentTime - initializingTime > 60*1000*10) {
if (currentTime - initializingTime > 60*1000*10) {
var result = rotateFile("api-usage-data.dat");
initializingTime = getCurrentTime();
match result {
string name => {
log:printInfo("File rotated successfully.");
}
error err => {
log:printError("Error occurred while rotating the file: " + err.message);
log:printError("Error occurred while rotating the file: ", err = err);
}
}
}
Expand All @@ -136,10 +135,10 @@ function writeEventToFile(EventDTO eventDTO) {
} finally {
match charChannel.close() {
error sourceCloseError => {
log:printError("Error occured while closing the channel: " + sourceCloseError.message);
log:printError("Error occured while closing the channel: ", err = sourceCloseError);
}
() => {
log:printInfo("Source channel closed successfully.");
log:printDebug("Source channel closed successfully.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function multipartSender(string file) returns http:Response {
request.addHeader("FileName", file);
request.addHeader("Accept", "application/json");
request.setBodyParts(bodyParts);
io:println(request);
var returnResponse = clientEP->post("/micro-gateway/v0.9/usage/upload-file",request);

match returnResponse {
Expand All @@ -28,7 +27,7 @@ function multipartSender(string file) returns http:Response {
string errorMessage = "Error occurred while sending multipart request: SC " + 500;
response.setPayload(errorMessage);
response.statusCode = 500;
log:printError(errorMessage);
log:printError(errorMessage, err = err);
return response;
}
http:Response returnResult => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public function rotateFile(string fileName) returns string|error {
internal:Path fileToZip = new(fileName);
match internal:compress(fileToZip, zipLocation) {
error compressError => {
log:printError("Error occurred while compressing the file: " + compressError.message);
log:printError("Error occurred while compressing the file: ", err = compressError);
return compressError;
}
() => {
Expand Down

0 comments on commit 1034d30

Please sign in to comment.