1.0.4 • Published 9 years ago
optimus-image-store v1.0.4
optimus-image-store
Overview
이 프로젝트는 옵티머스 이미지 중 스토어 모듈에 해당하는 프로젝트입니다.
주 기능은 AWS 환경의 Database(DynamoDB)와 파일 저장소(S3)를 관리합니다.
- registerTask - 작업 정보 등록
- registerResult - 작업 결과 등록
- registerImageStore - 이미지를 파일 저장소에 등록
- getBatchList - 배치 목록 리스트 조회
- registerBatch - 배치 작업 정보 등록
- updateBatchStatus - 배치 목록 상태 업데이트
Install
git clone <this repo>
Initialize
DB 체크 및 파일 저장소 체크를 하며 초기화가 완료되면 이벤트를 발생시킵니다.
var optimusStore = require('optimus-image-store');
// AWS config
var awsConfig = {
accessKeyId: your accessKey",
secretAccessKey: your secretAccessKey,
region : your region,
sslEnabled" : ssl option,
apiVersions" : {
"dynamodb" : "2012-08-10",
"s3" : "2006-03-01"
}
};
// See: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html
// file config
var fileConfig = {
bucketName : your S3 bucketName,
domain : your S3(or CDN) domain,
filePath : your S3 file path,
batchPath : your S3 file path under batch file path",
batchBackupPath" : your S3 file path under batch file backup path
};
// config setting
optimusStore.setConfig(awsConfig, config.fileConfig);
// config changed
optimusStore.on("CONFIG_CHANGED", function(err){
// TODO
});
Get result
제공되는 기능의 결과를 받는 방법입니다.
- event
var param = {
// your param
};
optimusStore.registerTask(param, "event name");
optimusStore.on("event name", function(err, data){
// TODO
});
- callback function
var param = {
// your param
};
optimusStore.registerTask(param, function(err, data){
// TODO
});
- common callback function
// set common callback
optimusStore.setCallback(commonCallback);
var param = {
// your param
};
optimusStore.registerTask(param, "callback name");
function commonCallback(err, data, callbackName) {
if(callbackName === "callback name") {
// TODO
}
}
registerTask(param, event name or callback function)
작업 시작 정보를 등록합니다.
var param = {
type : 'R', // task type (B-Batch, R-Realtime)
productId : // product id (length = 8)
taskStartDatetime : optimusStore.getDate("YYYYMMDDHH24MISS") //date string (length = 14)
};
// event 처리시
optimusStore.registerTask(param, function(err, data){
// TODO
});
registerResult(param, event name or callback function)
작업 결과를 등록합니다.
var param = registerTask 에 전달한 param;
// 작업 성공 결과
param.success = boolean;
// 작업 실패시
param.errorCode = 'S'; // 작업 에러 코드
param.errorDescription = 'error description'; // 작업 에러 상세 내용
optimusStore.registerResult(param, function(err, data){
// TODO
});
registerImageStore(param, event name or callback function)
캡처된 이미지 파일들을 파일 저장소에 등록합니다.
var param = {
productId : // product id (length = 8)
imagePath : // source path on local file system to upload to S3
};
optimusStore.registerImageStore(param, function(err, data){
// TODO
var path = data.path; //batch list
});
getBatchList(fileName, event name or callback function)
S3의 배치 파일을 읽어 리스트로 전달합니다.
var fileName = //batch list file name
optimusStore.getBatchList(fileName, function(err, data){
// TODO
var list = data.productList; //new path to upload images
});
registerBatch(param, event name or callback function)
배치 작업 시작 정보를 등록합니다.
var params = {
type : 'B', // task type (B-Batch, R-Realtime)
totalCount : //batch list count,
taskStartDatetime : optimusStore.getDate("YYYYMMDDHH24MISS") //date string (length = 14)
};
optimusStore.registerBatch(param, function(err, data){
// TODO
});
updateBatchStatus()
배치정보의 상태를 업데이트 합니다.
optimusStore.updateBatchStatus();