每次我在 Akka.NET 中创建一个类型的新对象时。该类型的整个 Journal 被加载到构造函数中
我的测试:
[Test, Category("Integration")]
public async Task Should_Persist_Actor()
{
var model = Mocks.Fake.Contact();
await Actors.ContactActor.Ask(new CreateContactCommand(model, "unit test", DateTime.Now));
var context = new MyTestContext("xxx");
using (context)
{
var found = context.Set<Contact>().FirstOrDefault(x => x.Id == model.Id);
Assert.IsNotNull(found);
}
}
这是不断受到打击的构造函数,日志中的每个条目一次
public sealed class CreateContactCommand : AuditCommandBase<Contact, CreateContactEvent>, ICommand<Contact, CreateContactEvent>
{
private readonly ILogger _logger = LogManager.GetCurrentClassLogger();
public CreateContactCommand(Contact obj, string auditUser, DateTime auditTime) : base(obj, auditUser, auditTime)
{
// This gets hit for everything in the journal db
_logger.Debug("Create Contact Command Ctor");
}
}
如果我截断日志,我的测试会立即通过。如果日志中有数据,它会为每个项目命中类型的构造函数......