초기커밋
This commit is contained in:
74
ServerBase/S3/S3Connector.cs
Normal file
74
ServerBase/S3/S3Connector.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
|
||||
using ServerCore;
|
||||
|
||||
|
||||
using MODULE_ID = System.UInt32;
|
||||
using SORT_ORDER_NO = System.Int32;
|
||||
|
||||
|
||||
namespace ServerBase;
|
||||
|
||||
public partial class S3Connector : S3ConnectorBase, IModule, IInitializer
|
||||
{
|
||||
private readonly ModuleContext m_module_context;
|
||||
|
||||
public S3Connector(ModuleContext moduleContext)
|
||||
: base()
|
||||
{
|
||||
m_module_context = moduleContext;
|
||||
}
|
||||
|
||||
private static (string accessKey, string secretKey, string regionName) getConfigParamsOrThrow(ModuleContext context)
|
||||
{
|
||||
if (context.getConfigParam() is not ConfigParam param)
|
||||
throw new InvalidCastException("IConfigParam must be of type S3ConnectorBase.ConfigParam !!!");
|
||||
|
||||
return (
|
||||
param.AccessKey ?? throw new InvalidOperationException("AccessKey is null !!!"),
|
||||
param.SecretKey ?? throw new InvalidOperationException("SecretKey is null !!!"),
|
||||
param.Region ?? throw new InvalidOperationException("Region is null !!!")
|
||||
);
|
||||
}
|
||||
|
||||
public async Task<Result> onInit()
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
var result = new Result();
|
||||
|
||||
var module_context = getModuleContext();
|
||||
var config_param = module_context.getConfigParam() as ConfigParam;
|
||||
NullReferenceCheckHelper.throwIfNull(config_param, () => $"config_param is null !!!");
|
||||
|
||||
var is_success = createS3Client(config_param.AccessKey, config_param.SecretKey, config_param.Region);
|
||||
if (false == is_success)
|
||||
{
|
||||
err_msg = $"Failed to createS3Client() !!! : {config_param.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.S3ClientCreateFailed, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
public async Task<Result> startModule()
|
||||
{
|
||||
var result = new Result();
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
public async Task<Result> stopModule()
|
||||
{
|
||||
var result = new Result();
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
public ModuleContext getModuleContext() => m_module_context;
|
||||
}
|
||||
Reference in New Issue
Block a user