초기커밋
This commit is contained in:
62
ServerBase/DB/MongoDb/MongoDbConnector.cs
Normal file
62
ServerBase/DB/MongoDb/MongoDbConnector.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using MongoDB.Driver;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
|
||||
|
||||
namespace ServerBase;
|
||||
|
||||
public partial class MongoDbConnector : MongoDbConnectorBase, IModule, IInitializer
|
||||
{
|
||||
private readonly ModuleContext m_module_context;
|
||||
|
||||
public MongoDbConnector(ModuleContext moduleContext)
|
||||
: base()
|
||||
{
|
||||
m_module_context = moduleContext;
|
||||
}
|
||||
|
||||
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, var db_list) = await initAndVerifyDb( config_param.ConnectionString
|
||||
, config_param.MinConnectionPoolSize
|
||||
, config_param.MaxConnectionPoolSize
|
||||
, config_param.WaitQueueTimeoutSecs );
|
||||
if(false == is_success)
|
||||
{
|
||||
err_msg = $"Failed to initAndVerifyDb() !!! : {config_param.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.MongoDbInitAndVefifyDbFailed, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
|
||||
return 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;
|
||||
|
||||
public string toBasicString()
|
||||
{
|
||||
return $"{m_module_context.toBasicString()} - {this.getTypeName()}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user