connectors_utility 8.6.0.4.pre.20221114T235434Z → 8.6.0.4.pre.20221115T000648Z

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/connectors/registry.rb +52 -0
  3. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5925861ca9c2d09d5a4b27cbb1262e7dee74420815b0df1988d97b5f1c4cbb3b
4
- data.tar.gz: 06bc7686285b134ac9198bb8ad3579b759fda60d2e4962e1fe4fc730828a8428
3
+ metadata.gz: ceb30af08ba8499ef1904431c3f76c306920553c8c3650168e3a5204034c8dc5
4
+ data.tar.gz: 57c105b727b1490fcb1a9811c242e657513c829a0546a9f1ae15b2f342165e75
5
5
  SHA512:
6
- metadata.gz: ffb17fd4a35bbecacddc59b018b20b3d24ef1581e5ca6b182dc73aa42100da4976fbb0d2e2e2504767769a0ea259e3091c877e5ac8ad58683cd1a45022215a0b
7
- data.tar.gz: ce59bc3313006d3324d62c572cf9c743028cab4d052ea985a7ca183bf3bd9f55ad5edd6bf93fabd4eb54f2614226c1d8ed195a236d6916cb16682575c902b099
6
+ metadata.gz: bba6b08e29142cc0e738d39ccf7480b00a13b731a810f78f00d23c9e4225ac3c62706cb88d2cb385d83a91133a4ed166fd0606fac43d6b85338575a8bbfa8062
7
+ data.tar.gz: 7df0bc92dff1d78661c2a1d5e0481173fca5b3f0a228720532129d2bd0307254de4c963893db0add89fa73ee39161ef34ea2498d1d7bf0b492584539b79de2a4
@@ -0,0 +1,52 @@
1
+ #
2
+ # Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ # or more contributor license agreements. Licensed under the Elastic License;
4
+ # you may not use this file except in compliance with the Elastic License.
5
+ #
6
+
7
+ module Connectors
8
+ class Factory
9
+ attr_reader :connectors
10
+
11
+ def initialize
12
+ @connectors = {}
13
+ end
14
+
15
+ def register(name, klass)
16
+ @connectors[name] = klass
17
+ end
18
+
19
+ def registered?(name)
20
+ @connectors.has_key?(name)
21
+ end
22
+
23
+ def connector_class(name)
24
+ @connectors[name]
25
+ end
26
+
27
+ def connector(name, configuration, job_description: {})
28
+ klass = connector_class(name)
29
+ if klass.present?
30
+ return klass.new(configuration: configuration, job_description: job_description)
31
+ end
32
+ raise "Connector #{name} is not yet registered. You need to register it before use"
33
+ end
34
+
35
+ def registered_connectors
36
+ @connectors.keys.sort
37
+ end
38
+ end
39
+
40
+ REGISTRY = Factory.new
41
+
42
+ require_relative './example/connector'
43
+ REGISTRY.register(Connectors::Example::Connector.service_type, Connectors::Example::Connector)
44
+
45
+ # loading plugins (might replace this with a directory scan and conventions on names)
46
+ require_relative './gitlab/connector'
47
+
48
+ REGISTRY.register(Connectors::GitLab::Connector.service_type, Connectors::GitLab::Connector)
49
+
50
+ require_relative 'mongodb/connector'
51
+ REGISTRY.register(Connectors::MongoDB::Connector.service_type, Connectors::MongoDB::Connector)
52
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: connectors_utility
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.6.0.4.pre.20221114T235434Z
4
+ version: 8.6.0.4.pre.20221115T000648Z
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-14 00:00:00.000000000 Z
11
+ date: 2022-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -104,6 +104,7 @@ files:
104
104
  - NOTICE.txt
105
105
  - lib/connectors/connector_status.rb
106
106
  - lib/connectors/crawler/scheduler.rb
107
+ - lib/connectors/registry.rb
107
108
  - lib/connectors/sync_status.rb
108
109
  - lib/connectors_utility.rb
109
110
  - lib/core/connector_settings.rb