blob: 4828320d8e6b03c66e72043352da111788cda792 (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "ireplyhandler.h"
#include "ithrottlepolicy.h"
namespace mbus {
/**
* To facilitate several configuration parameters to the {@link MessageBus#createSourceSession(ReplyHandler,
* SourceSessionParams)}, all parameters are held by this class. This class has reasonable default values for each
* parameter.
*
* @author Simon Thoresen Hult
*/
class SourceSessionParams {
private:
IReplyHandler *_replyHandler;
IThrottlePolicy::SP _throttlePolicy;
duration _timeout;
public:
/**
* This constructor will set default values for all parameters.
*/
SourceSessionParams();
/**
* Returns the policy to use for throttling output.
*
* @return The policy.
*/
IThrottlePolicy::SP getThrottlePolicy() const;
/**
* Sets the policy to use for throttling output.
*
* @param throttlePolicy The policy to set.
* @return This, to allow chaining.
*/
SourceSessionParams &setThrottlePolicy(IThrottlePolicy::SP throttlePolicy);
/**
* Returns the total timeout parameter.
*
* @return The total timeout parameter.
*/
duration getTimeout() const { return _timeout; }
/**
* Returns the number of seconds a message can spend trying to succeed.
*
* @return The timeout in seconds.
*/
SourceSessionParams &setTimeout(duration timeout);
/**
* Returns whether or not a reply handler has been assigned to this.
*
* @return True if a handler is set.
*/
bool hasReplyHandler() const;
/**
* Returns the handler to receive incoming replies. If you call this method without first assigning a
* reply handler to this object, you wil de-ref null.
*
* @return The handler.
*/
IReplyHandler &getReplyHandler() const;
/**
* Sets the handler to receive incoming replies.
*
* @param handler The handler to set.
* @return This, to allow chaining.
*/
SourceSessionParams &setReplyHandler(IReplyHandler &handler);
};
} // namespace mbus
|