-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.js
153 lines (134 loc) · 4.59 KB
/
constants.js
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
export const SERVICE_PREFIX = '@gdbots/pbjx/';
export const EVENT_PREFIX = SERVICE_PREFIX;
const t = id => `${EVENT_PREFIX}${id}`;
/**
* When using a {@see ContainerAwareServiceLocator} the services
* and parameters are located using these identifiers.
*
* @link https://martinfowler.com/articles/injection.html#UsingAServiceLocator
*
* @type {Object}
*/
export const serviceIds = {
PREFIX: SERVICE_PREFIX,
// core pbjx services
PBJX: t('pbjx'),
DISPATCHER: t('dispatcher'),
EXCEPTION_HANDLER: t('exception_handler'),
LOCATOR: t('locator'),
// bus configs (e.g. firehose, http, in_memory, lambda)
COMMAND_BUS_TRANSPORT: t('command_bus/transport'),
EVENT_BUS_TRANSPORT: t('event_bus/transport'),
REQUEST_BUS_TRANSPORT: t('request_bus/transport'),
// transports
TRANSPORT_PREFIX: t('transports/'),
TRANSPORT_FIREHOSE: t('transports/firehose'),
TRANSPORT_HTTP: t('transports/http'),
TRANSPORT_HTTP_ENDPOINT: t('transports/http/endpoint'),
TRANSPORT_IN_MEMORY: t('transports/in_memory'),
TRANSPORT_LAMBDA: t('transports/lambda'),
// handlers
CHECK_HEALTH_HANDLER: t('check_health_handler'),
ECHO_REQUEST_HANDLER: t('echo_request_handler'),
};
/**
* Access Tokens (aka Bearer Token) can be used with transports
* that support authentication via an "Authorization" header.
* When reading/writing the access tokens, use these keys.
*/
export const ACCESS_TOKEN_STORAGE_KEY = 'pbjx.accessToken';
export const ACCESS_TOKEN_ENV_KEY = 'PBJX_ACCESS_TOKEN';
/**
* Suffixes are typically used by {@see Pbjx.trigger}
* The actual event name is a combination of curies, mixins, etc. on the
* message plus a suffix. The event payload will be a PbjxEvent or a
* subclass of that.
*
* @see {PbjxEvent}
*/
export const SUFFIX_BIND = 'bind';
export const SUFFIX_VALIDATE = 'validate';
export const SUFFIX_ENRICH = 'enrich';
export const SUFFIX_BEFORE_HANDLE = 'before_handle';
export const SUFFIX_AFTER_HANDLE = 'after_handle';
export const SUFFIX_CREATED = 'created';
export const SUFFIX_UPDATED = 'updated';
export const SUFFIX_DELETED = 'deleted';
export const SUFFIX_EXCEPTION = 'exception';
/**
* Occurs during a Pbjx.trigger call when throwEx is false, which
* means the error doesn't block/throw and is dispatched instead.
*/
export const TRIGGER_EXCEPTION = t('trigger_exception');
/**
* Occurs prior to an expection being thrown during the handling phase of a command.
* This is not announced during validate, enrich or the transport send.
*
* @see {BusExceptionEvent}
*/
export const COMMAND_BUS_EXCEPTION = t('command_bus.exception');
/**
* Occurs during event dispatching, where events are actually handled. If the
* subscriber throws an exception and the EventExecutionFailed also fails
* to be handled, then this event is announced. This should be very rare.
*
* @see {BusExceptionEvent}
*/
export const EVENT_BUS_EXCEPTION = t('event_bus.exception');
/**
* Occurs during request handling when an exception is not properly
* handled and converted to a RequestFailedResponse response.
*
* @see {BusExceptionEvent}
*/
export const REQUEST_BUS_EXCEPTION = t('request_bus.exception');
/**
* Occurs prior to the message being sent by the transport.
*
* @see {TransportEvent}
*/
export const TRANSPORT_BEFORE_SEND = t('transport.before_send');
/**
* Occurs after the message has been successfully sent by the transport.
*
* @see {TransportEvent}
*/
export const TRANSPORT_AFTER_SEND = t('transport.after_send');
/**
* Occurs if the transport throws an exception during the send.
*
* @see {TransportExceptionEvent}
*/
export const TRANSPORT_SEND_EXCEPTION = t('transport.send_exception');
/**
* Occurs when the {@see HttpTransport} receives an Envelope from a PBJX HTTP service.
* The envelope sometimes carries out of band information and an event subscriber
* would need to extract that data to make use of it.
*
* @see {EnvelopeReceivedEvent}
*/
export const TRANSPORT_HTTP_ENVELOPE_RECEIVED = t('transport.http.envelope_received');
/**
* Occurs before a job/task/message has been handled by a consumer.
*
* @see {PbjxEvent}
*/
export const CONSUMER_BEFORE_HANDLE = t('consumer.before_handle');
/**
* Occurs after a job/task/message has been handled by a consumer.
*
* @see {PbjxEvent}
*/
export const CONSUMER_AFTER_HANDLE = t('consumer.after_handle');
/**
* Occurs if an exception is thrown during message handling.
*
* @see {PbjxEvent}
*/
export const CONSUMER_HANDLING_EXCEPTION = t('consumer.handling_exception');
/**
* Occurs after the consumer has stopped and finished its teardown.
*
* @see {PbjxEvent}
*/
export const CONSUMER_AFTER_TEARDOWN = t('consumer.after_teardown');