@itentialopensource/adapter-kafkav2 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +6 -0
- package/.eslintrc.js +18 -0
- package/.gitlab/.gitkeep +0 -0
- package/.gitlab/issue_templates/.gitkeep +0 -0
- package/.gitlab/issue_templates/Default.md +17 -0
- package/.gitlab/issue_templates/bugReportTemplate.md +76 -0
- package/.gitlab/issue_templates/featureRequestTemplate.md +14 -0
- package/.jshintrc +0 -0
- package/CHANGELOG.md +152 -0
- package/CODE_OF_CONDUCT.md +48 -0
- package/CONTRIBUTING.md +158 -0
- package/LICENSE +201 -0
- package/README.md +380 -0
- package/Release_Notes.md +0 -0
- package/adapter.js +814 -0
- package/error.json +178 -0
- package/package.json +71 -0
- package/pronghorn.json +44 -0
- package/propertiesSchema.json +198 -0
- package/refs?service=git-upload-pack +0 -0
- package/sampleProperties.json +41 -0
- package/test/integration/adapterTestIntegration.js +445 -0
- package/test/unit/adapterTestUnit.js +412 -0
- package/utils/artifactize.js +146 -0
- package/utils/packModificationScript.js +35 -0
- package/utils/pre-commit.sh +27 -0
- package/utils/setup.js +33 -0
- package/utils/testRunner.js +298 -0
- package/workflows/kafka_test.json +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2019 Itential, LLC
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
# Kafkav2 Adapter
|
|
2
|
+
|
|
3
|
+
This adapter is used to integrate the Itential Automation Platform (IAP) with the Kafka System. The documenation for kafkajs is available at [https://kafka.js.org/docs/getting-started]. The adapter utilizes the kafkjs library. to provide the integrations that are deemed pertinent to IAP. This ReadMe file is intended to provide information on this adapter.
|
|
4
|
+
|
|
5
|
+
>**Note**: It is possible that some integrations will be supported through the Kafka adapter while other integrations will not.
|
|
6
|
+
|
|
7
|
+
Itential provides information on all of its product adapters in the Customer Knowledge Base. Information in the [Customer Knowledge Base](https://itential.atlassian.net/servicedesk/customer/portals) is consistently maintained and goes through documentation reviews. As a result, it should be the first place to go for information.
|
|
8
|
+
|
|
9
|
+
For custom built adapters, it is a starting point to understand what you have built, provide the information for you to be able to update the adapter, and assist you with deploying the adapter into IAP.
|
|
10
|
+
|
|
11
|
+
## Versioning
|
|
12
|
+
|
|
13
|
+
Itential Product adapters utilize SemVer for versioning. The current version of the adapter can be found in the `package.json` file or viewed in the IAP GUI on the System page. For Open Source Adapters, the versions available can be found in the [Itential OpenSource Repository](https://www.npmjs.com/search?q=itentialopensource%2Fadapter).
|
|
14
|
+
|
|
15
|
+
## Release History
|
|
16
|
+
|
|
17
|
+
Any release prior to 1.0.0 is a pre-release. Initial builds of adapters are generally set up as pre-releases as there is often work that needs to be done to configure the adapter and make sure the authentication process to Kafka works appropriately.
|
|
18
|
+
|
|
19
|
+
Release notes can be viewed in CHANGELOG.md or in the [Customer Knowledge Base](https://itential.atlassian.net/servicedesk/customer/portals) for Itential adapters.
|
|
20
|
+
|
|
21
|
+
## Getting Started
|
|
22
|
+
|
|
23
|
+
These instructions will help you get a copy of the project on your local machine for development and testing. Reading this section is also helpful for deployments as it provides you with pertinent information on prerequisites and properties.
|
|
24
|
+
|
|
25
|
+
### Environment Prerequisites
|
|
26
|
+
|
|
27
|
+
The following is a list of required packages for an adapter.
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
Node.js
|
|
31
|
+
Git
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Adapter Prerequisites
|
|
35
|
+
|
|
36
|
+
The following list of packages are required for Itential product adapters or custom adapters that have been built utilizing the Itential Adapter Builder.
|
|
37
|
+
|
|
38
|
+
| Package | Description |
|
|
39
|
+
| ------- | ------- |
|
|
40
|
+
| @itentialopensource/adapter-utils | Runtime library classes for all adapters; includes request handling, connection, throttling, and translation. |
|
|
41
|
+
| ajv | Required for validation of adapter properties to integrate with Kafka. |
|
|
42
|
+
| fs-extra | Utilized by the node scripts that are included with the adapter; helps to build and extend the functionality. |
|
|
43
|
+
| readline-sync | Utilized by the testRunner script that comes with the adapter; helps to test unit and integration functionality. |
|
|
44
|
+
|
|
45
|
+
### Additional Prerequisites for Development and Testing
|
|
46
|
+
|
|
47
|
+
If you are developing and testing a custom adapter, or have testing capabilities on an Itential product adapter, you will need to install these packages as well.
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
chai
|
|
51
|
+
eslint
|
|
52
|
+
eslint-config-airbnb-base
|
|
53
|
+
eslint-plugin-import
|
|
54
|
+
eslint-plugin-json
|
|
55
|
+
mocha
|
|
56
|
+
nyc
|
|
57
|
+
testdouble
|
|
58
|
+
winston
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Specific Prerequisites
|
|
62
|
+
|
|
63
|
+
At the current time the Kafka adapter does not utilize the adapter utilities as it makes use of the following library instead.
|
|
64
|
+
|
|
65
|
+
| Package | Description |
|
|
66
|
+
| ------- | ------- |
|
|
67
|
+
| kafkajs | Library that provides kafka connectivity through nodejs. |
|
|
68
|
+
|
|
69
|
+
### Creating a Workspace
|
|
70
|
+
|
|
71
|
+
The following provides a local copy of the repository along with adapter dependencies.
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
git clone git@gitlab.com:\@itentialopensource/adapters/adapter-Kafkav2
|
|
75
|
+
npm install
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Adapter Properties and Descriptions
|
|
79
|
+
|
|
80
|
+
This section defines **all** the properties that are available for the adapter, including detailed information on what each property is for. If you are not using certain capabilities with this adapter, you do not need to define all of the properties. An example of how the properties for this adapter can be used with tests or IAP are provided in the **Installation** section.
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"host": "localhost",
|
|
85
|
+
"port": 9092,
|
|
86
|
+
"interval_time": 5000,
|
|
87
|
+
"stub": false,
|
|
88
|
+
"parseMessage": true,
|
|
89
|
+
"wrapMessage": "myKey",
|
|
90
|
+
"client": {
|
|
91
|
+
"connectTimeout": 10000,
|
|
92
|
+
"requestTimeout": 30000,
|
|
93
|
+
"autoConnect": true,
|
|
94
|
+
"connectRetryOptions": {},
|
|
95
|
+
"idleConnection": 300000,
|
|
96
|
+
"reconnectOnIdle": true,
|
|
97
|
+
"maxAsyncRequests": 10,
|
|
98
|
+
"sslOptions": {},
|
|
99
|
+
"sasl": {}
|
|
100
|
+
},
|
|
101
|
+
"producer": {
|
|
102
|
+
"requireAcks": 1,
|
|
103
|
+
"ackTimeoutMs": 100,
|
|
104
|
+
"partitionerType": 0
|
|
105
|
+
},
|
|
106
|
+
"consumer": {
|
|
107
|
+
"groupId": "kafka-node-group",
|
|
108
|
+
"autoCommit": false,
|
|
109
|
+
"autoCommitIntervalMs": 5000,
|
|
110
|
+
"fetchMaxWaitMs": 100,
|
|
111
|
+
"fetchMinBytes": 1,
|
|
112
|
+
"fetchMaxBytes": 1048576,
|
|
113
|
+
"fromOffset": true,
|
|
114
|
+
"encoding": "utf8",
|
|
115
|
+
"keyEncoding": "utf8"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Topic Properties
|
|
121
|
+
|
|
122
|
+
Operator can configure message filtering per topic by providing filters in `topics[*].subscriberInfo[*].filters` property.
|
|
123
|
+
Regular expressions are accepted, guide on how to build regular expressions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
|
|
124
|
+
Operator shall stick to simple regular expressions as complex ones could cause catastrophic backtracking problem
|
|
125
|
+
https://www.regular-expressions.info/catastrophic.html leading to adapter being unresponsive.
|
|
126
|
+
|
|
127
|
+
Example of adapter's configuration with filtering applied:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
"topics": [
|
|
131
|
+
{
|
|
132
|
+
"name": "t1",
|
|
133
|
+
"always": true,
|
|
134
|
+
"subscriberInfo": [
|
|
135
|
+
{
|
|
136
|
+
"subname": "default",
|
|
137
|
+
"filters": [
|
|
138
|
+
"PIXI",
|
|
139
|
+
"DRED",
|
|
140
|
+
"[abc]",
|
|
141
|
+
"F: (\\w+), L: (\\w+)",
|
|
142
|
+
"\\d{3,4}"
|
|
143
|
+
],
|
|
144
|
+
"rabbit": "kafka",
|
|
145
|
+
"throttle": {}
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
When operator skips to provide `filters` property or the property contains no actual filters set, then all messages are passed.
|
|
153
|
+
|
|
154
|
+
### Connection Properties
|
|
155
|
+
|
|
156
|
+
These base properties are used to connect to Kafka upon the adapter initially coming up. It is important to set these properties appropriately.
|
|
157
|
+
Kafka server location is set either by providing (host, port) tuple or by providing hostList property
|
|
158
|
+
|
|
159
|
+
| Property | Description |
|
|
160
|
+
| ------- | ------- |
|
|
161
|
+
| host | Optional. A fully qualified domain name or IP address.|
|
|
162
|
+
| port | Required if `host` set. Used to connect to the server.|
|
|
163
|
+
| hostList | Optional. A string of kafka broker/host combination delimited by comma|
|
|
164
|
+
| interval_time | Optional. The Kafka adapter keeps information about topics and offsets in memory in order to be more efficient. In order to work across restarts the adapter must persist the data. So the data is written into the .topics.json file. This write time defines how often to write the file.|
|
|
165
|
+
| stub | Optional. Slightlu different meaning than normal, this is just telling the adapter whether to run the write topics interval. This should always be false unless you are running standalone tests.|
|
|
166
|
+
|
|
167
|
+
#### Important
|
|
168
|
+
When adapter works in consumer configuration: `autoCommit:false` `fromOffset:true` current offset setting on adapter startup is loaded from .topic.json file for each (topic:partition).
|
|
169
|
+
Setting of property `interval_time` affects adapter's behaviour after adapter restart.
|
|
170
|
+
If adapter is restarted before .topics.json is updated with latest offset for given (topic:partition), then after adapter goes up, consumer offsets are set based on .topic.json content or outOfRange resolution. Depending on the offset being set all messages present on kafka server with offset=(consumer offset + 1) will be read and emitted to subscriber (e.g. OperationManager) after restart. This can trigger duplicated jobs run by OperationManager. To avoid that, operator shall wait `interval_time` after last message read by consumer before restarting adapter to avoid duplicated jobs.
|
|
171
|
+
|
|
172
|
+
### Client Properties
|
|
173
|
+
|
|
174
|
+
The following properties are used to define the Kafka Client. These properties all have default values in the adapter and in Kafka. Definitions are taken from kafka-node page as these properties are directly passed to Kafka.
|
|
175
|
+
|
|
176
|
+
| Property | Description |
|
|
177
|
+
| ------- | ------- |
|
|
178
|
+
| connectTimeout | ms it takes to wait for a successful connection before moving to the next host.|
|
|
179
|
+
| requestTimeout | ms for a kafka request to timeout .|
|
|
180
|
+
| autoConnect | automatically connect when KafkaClient is instantiated otherwise you need to manually call connect.|
|
|
181
|
+
| connectRetryOptions | object hash that applies to the initial connection.|
|
|
182
|
+
| idleConnection | ms before allowing the broker to disconnect an idle connection from a client. |
|
|
183
|
+
| reconnectOnIdle | when the connection is closed due to client idling, client will attempt to auto-reconnect.|
|
|
184
|
+
| maxAsyncRequests | maximum async operations at a time toward the kafka cluster..|
|
|
185
|
+
| sslOptions | Object, options to be passed to the tls broker sockets, ex. { rejectUnauthorized: false }.|
|
|
186
|
+
| sasl | Object, SASL authentication configuration (only SASL/PLAIN is currently supported), ex. { mechanism: 'plain', username: 'foo', password: 'bar' }.|
|
|
187
|
+
|
|
188
|
+
### Producer Properties
|
|
189
|
+
|
|
190
|
+
The following properties are used to define the Kafka Producer. These properties all have default values in Kafka. Definitions are taken from kafka-node page as these properties are directly passed to Kafka.
|
|
191
|
+
|
|
192
|
+
| Property | Description |
|
|
193
|
+
| ------- | ------- |
|
|
194
|
+
| requireAcks | Configuration for when to consider a message as acknowledged, default 1. |
|
|
195
|
+
| ackTimeoutMs | The amount of time in milliseconds to wait for all acks before considered, default 100ms.|
|
|
196
|
+
| partitionerType | Partitioner type (default = 0, random = 1, cyclic = 2, keyed = 3, custom = 4), default 0.|
|
|
197
|
+
|
|
198
|
+
### Consumer Properties
|
|
199
|
+
|
|
200
|
+
The following properties are used to define the Kafka Consumer. These properties all have default values in Kafka. Definitions are taken from kafka-node page as these properties are directly passed to Kafka.
|
|
201
|
+
|
|
202
|
+
| Property | Description |
|
|
203
|
+
| ------- | ------- |
|
|
204
|
+
| groupId | consumer group id, default `kafka-node-group`.|
|
|
205
|
+
| autoCommit | Auto commit config.|
|
|
206
|
+
| autoCommitIntervalMs | |
|
|
207
|
+
| fetchMaxWaitMs | max wait time is the maximum amount of time in milliseconds to block waiting if insufficient data is available at the time the request is issued, default 100ms|
|
|
208
|
+
| fetchMinBytes | minimum number of bytes of messages that must be available to give a response, default 1 byte.|
|
|
209
|
+
| fetchMaxBytes | maximum bytes to include in the message set for this partition. This helps bound the size of the response.|
|
|
210
|
+
| fromOffset | If set true, consumer will fetch message from the given offset in the payloads.|
|
|
211
|
+
| encoding | If set to 'buffer', values will be returned as raw buffer objects..|
|
|
212
|
+
| keyEncoding | |
|
|
213
|
+
|
|
214
|
+
## Testing an Itential Product Adapter
|
|
215
|
+
|
|
216
|
+
Mocha is generally used to test all Itential Product Adapters. There are unit tests as well as integration tests performed. Integration tests can generally be run as standalone using mock data and running the adapter in stub mode, or as integrated. When running integrated, every effort is made to prevent environmental failures, however there is still a possibility.
|
|
217
|
+
|
|
218
|
+
### Unit Testing
|
|
219
|
+
|
|
220
|
+
Unit Testing includes testing basic adapter functionality as well as error conditions that are triggered in the adapter prior to any integration. There are two ways to run unit tests. The prefered method is to use the testRunner script; however, both methods are provided here.
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
```json
|
|
224
|
+
node utils/testRunner --unit
|
|
225
|
+
|
|
226
|
+
npm run test:unit
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
To add new unit tests, edit the `test/unit/adapterTestUnit.js` file. The tests that are already in this file should provide guidance for adding additional tests.
|
|
230
|
+
|
|
231
|
+
### Integration Testing - Standalone
|
|
232
|
+
|
|
233
|
+
Standalone Integration Testing requires mock data to be provided with the entities. If this data is not provided, standalone integration testing will fail. When the adapter is set to run in stub mode (setting the stub property to true), the adapter will run through its code up to the point of making the request. It will then retrieve the mock data and return that as if it had received that data as the response from Kafka. It will then translate the data so that the adapter can return the expected response to the rest of the Itential software. Standalone is the default integration test.
|
|
234
|
+
|
|
235
|
+
Similar to unit testing, there are two ways to run integration tests. Using the testRunner script is better because it prevents you from having to edit the test script; it will also resets information after testing is complete so that credentials are not saved in the file.
|
|
236
|
+
|
|
237
|
+
```json
|
|
238
|
+
node utils/testRunner
|
|
239
|
+
answer no at the first prompt
|
|
240
|
+
|
|
241
|
+
npm run test:integration
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
To add new integration tests, edit the `test/integration/adapterTestIntegration.js` file. The tests that are already in this file should provide guidance for adding additional tests.
|
|
245
|
+
|
|
246
|
+
### Integration Testing
|
|
247
|
+
|
|
248
|
+
Integration Testing requires connectivity to Kafka. By using the testRunner script it prevents you from having to edit the integration test. It also resets the integration test after the test is complete so that credentials are not saved in the file.
|
|
249
|
+
|
|
250
|
+
> **Note**: These tests have been written as a best effort to make them work in most environments. However, the Adapter Builder often does not have the necessary information that is required to set up valid integration tests. For example, the order of the requests can be very important and data is often required for `creates` and `updates`. Hence, integration tests may have to be enhanced before they will work (integrate) with Kafka. Even after tests have been set up properly, it is possible there are environmental constraints that could result in test failures. Some examples of possible environmental issues are customizations that have been made within Kafka which change order dependencies or required data.
|
|
251
|
+
|
|
252
|
+
```json
|
|
253
|
+
node utils/testRunner
|
|
254
|
+
answer yes at the first prompt
|
|
255
|
+
answer all other questions on connectivity and credentials
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Test should also be written to clean up after themselves. However, it is important to understand that in some cases this may not be possible. In addition, whenever exceptions occur, test execution may be stopped, which will prevent cleanup actions from running. It is recommended that tests be utilized in dev and test labs only.
|
|
259
|
+
|
|
260
|
+
> **Reminder**: Do not check in code with actual credentials to systems.
|
|
261
|
+
|
|
262
|
+
## Installing an Itential Product Adapter
|
|
263
|
+
|
|
264
|
+
1. Set up the name space location in your IAP node_modules.
|
|
265
|
+
|
|
266
|
+
```json
|
|
267
|
+
cd /opt/pronghorn/current/node_modules
|
|
268
|
+
if the @itentialopensource directory does not exist, create it:
|
|
269
|
+
mkdir @itentialopensource
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
1. Clone the adapter into your IAP environment.
|
|
273
|
+
|
|
274
|
+
```json
|
|
275
|
+
cd \@itentialopensource
|
|
276
|
+
git clone git@gitlab.com:\@itentialopensource/adapters/adapter-Kafka
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
1. Install the dependencies for the adapter.
|
|
280
|
+
|
|
281
|
+
```json
|
|
282
|
+
cd adapter-Kafka
|
|
283
|
+
npm install
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
1. Add the adapter properties for Kafka (created from Adapter Builder) to the `properties.json` file for your Itential build. You will need to change the credentials and possibly the host information below.
|
|
287
|
+
[Kafka sample properties](sampleProperties.json)
|
|
288
|
+
|
|
289
|
+
1. Restart IAP
|
|
290
|
+
|
|
291
|
+
```json
|
|
292
|
+
systemctl restart pronghorn
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Installing a Custom Adapter
|
|
296
|
+
|
|
297
|
+
If you built this as a custom adapter through the Adapter Builder, it is recommended you go through setting up a development environment and testing the adapter before installing it. There is often configuration and authentication work that is required before the adapter will work in IAP.
|
|
298
|
+
|
|
299
|
+
1. Move the adapter into the IAP `node_modules` directory.
|
|
300
|
+
|
|
301
|
+
```json
|
|
302
|
+
Depending on where your code is located, this process is different.
|
|
303
|
+
Could be a tar, move, untar
|
|
304
|
+
Could be a git clone of a repository
|
|
305
|
+
Could also be a cp -R from a coding directory
|
|
306
|
+
Adapter should be placed into: /opt/pronghorn/current/node_modules/\@itentialopensource
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
1. Follow Steps 3-5 (above) to install an Itential adapter to load your properties, dependencies and restart IAP.
|
|
310
|
+
|
|
311
|
+
## Using this Adapter
|
|
312
|
+
|
|
313
|
+
The `adapter.js` file contains the calls the adapter makes available to the rest of the Itential Platform. The API detailed for these calls should be available through JSDOC. The following is a brief summary of the calls.
|
|
314
|
+
|
|
315
|
+
### Generic Adapter Calls
|
|
316
|
+
|
|
317
|
+
```json
|
|
318
|
+
connect()
|
|
319
|
+
The connect call is run when the Adapter is first loaded by he Itential Platform. It validates the properties have been provided correctly.
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
```json
|
|
323
|
+
healthCheck(callback)
|
|
324
|
+
Insures that the adapter can communicate with Kafka. The actual call that is used is defined in the adapter properties.
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Specific Adapter Calls
|
|
328
|
+
|
|
329
|
+
Specific adapter calls are built based on the API of the Kafka. The Adapter Builder creates the proper method comments for generating JS-DOC for the adapter. This is the best way to get information on the calls.
|
|
330
|
+
|
|
331
|
+
## Troubleshooting the Adapter
|
|
332
|
+
|
|
333
|
+
### Connectivity Issues
|
|
334
|
+
|
|
335
|
+
1. Verify the adapter properties are set up correctly.
|
|
336
|
+
|
|
337
|
+
```json
|
|
338
|
+
Go into the Itential Platform GUI and verify/update the properties
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
1. Verify there is connectivity between the Itential Platform Server and Kafka Server.
|
|
342
|
+
|
|
343
|
+
```json
|
|
344
|
+
ping the ip address of Kafka server
|
|
345
|
+
try telnet to the ip address port of Kafka
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
1. Verify the credentials provided for Kafka.
|
|
349
|
+
|
|
350
|
+
```json
|
|
351
|
+
login to Kafka using the provided credentials
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
1. Verify the API of the call utilized for Kafka Healthcheck.
|
|
355
|
+
|
|
356
|
+
```json
|
|
357
|
+
Go into the Itential Platform GUI and verify/update the properties
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Functional Issues
|
|
361
|
+
|
|
362
|
+
Adapter logs are located in `/var/log/pronghorn`. In older releases of the Itential Platform, there is a `pronghorn.log` file which contains logs for all of the Itential Platform. In newer versions, adapters are logging into their own files.
|
|
363
|
+
|
|
364
|
+
## Contributing to Kafka
|
|
365
|
+
|
|
366
|
+
Please check out the [Contributing Guidelines](./CONTRIBUTING.md).
|
|
367
|
+
|
|
368
|
+
## License & Maintainers
|
|
369
|
+
|
|
370
|
+
### Maintained By
|
|
371
|
+
|
|
372
|
+
```json
|
|
373
|
+
Itential Product Adapters are maintained by the Itential Adapter Team.
|
|
374
|
+
Itential OpenSource Adapters are maintained by the community at large.
|
|
375
|
+
Custom Adapters are maintained by other sources.
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Product License
|
|
379
|
+
|
|
380
|
+
[Apache 2.0](./LICENSE)
|
package/Release_Notes.md
ADDED
|
File without changes
|