aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/test/helper/example_module.cpp
blob: 26dc184b163fe7ef9b09a40a5df188d8177cefb6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "example_module.h"

using namespace NBus;
using namespace NBus::NTest;

TExampleModule::TExampleModule()
    : TBusModule("TExampleModule")
{
    TBusQueueConfig queueConfig;
    queueConfig.NumWorkers = 5;
    Queue = CreateMessageQueue(queueConfig);
}

void TExampleModule::StartModule() {
    CreatePrivateSessions(Queue.Get());
    StartInput();
}

bool TExampleModule::Shutdown() {
    TBusModule::Shutdown();
    return true;
}

TBusServerSessionPtr TExampleModule::CreateExtSession(TBusMessageQueue&) {
    return nullptr;
}

TBusServerSessionPtr TExampleServerModule::CreateExtSession(TBusMessageQueue& queue) {
    TBusServerSessionPtr r = CreateDefaultDestination(queue, &Proto, TBusServerSessionConfig());
    ServerAddr = TNetAddr("localhost", r->GetActualListenPort());
    return r;
}

TExampleClientModule::TExampleClientModule() 
    : Source() 
{ 
} 

TBusServerSessionPtr TExampleClientModule::CreateExtSession(TBusMessageQueue& queue) {
    Source = CreateDefaultSource(queue, &Proto, TBusServerSessionConfig());
    Source->RegisterService("localhost");
    return nullptr;
}