nexo 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/app/jobs/nexo/api_clients.rb +7 -1
- data/app/jobs/nexo/sync_element_job.rb +2 -0
- data/app/jobs/nexo/update_remote_resource_job.rb +12 -0
- data/app/lib/nexo/errors.rb +2 -0
- data/app/models/nexo/client.rb +1 -2
- data/db/migrate/20250505192315_create_nexo_clients.rb +0 -1
- data/db/seeds.rb +26 -1
- data/lib/nexo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf53f0b9f6a1041943a11b96d6688fc0506528d29d855615fb651f56d7dfdb81
|
4
|
+
data.tar.gz: 1b707625c9f1f621daf84912c2bb2de01e008f4b7d7024c31dae0c7fa6019448
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 536a191c758d2ac7ccab8a5780a1d568820723571b9682382b71b5324de83109179882a1777b2a7380061e8289efec8c9c0e470c8f758ba2ec26a1c57117e575
|
7
|
+
data.tar.gz: 2f5509307f988bcf11bd57e7582713f7d2dd187f53a6e915ca43050c476363ea427c43cd811ce7a968c90422bf560e79f530aec7f4d4a4fcb001856a2e448514
|
@@ -7,6 +7,9 @@ module Nexo
|
|
7
7
|
|
8
8
|
queue_as :api_clients
|
9
9
|
|
10
|
+
# TODO!: configure good job queues and thread pools
|
11
|
+
# https://github.com/bensheldon/good_job?tab=readme-ov-file#optimize-queues-threads-and-processes
|
12
|
+
# TODO: make this configurable, so other job backends are allowed
|
10
13
|
good_job_control_concurrency_with(
|
11
14
|
perform_limit: 1,
|
12
15
|
|
@@ -18,7 +21,10 @@ module Nexo
|
|
18
21
|
retry_on(
|
19
22
|
GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError,
|
20
23
|
attempts: Float::INFINITY,
|
21
|
-
wait:
|
24
|
+
wait: :polynomially_longer,
|
25
|
+
jitter: 0.99,
|
26
|
+
# wait: ->(executions) { ((executions**4) + (Kernel.rand * (executions**4) * jitter)) + 2 }
|
27
|
+
# wait: ->(executions) { ((executions**3) + (Kernel.rand * (executions**3) * 0.5)) + 2 }
|
22
28
|
)
|
23
29
|
end
|
24
30
|
end
|
@@ -14,6 +14,8 @@ module Nexo
|
|
14
14
|
class SyncElementJob < BaseJob
|
15
15
|
limits_concurrency key: ->(element) { element.to_gid }
|
16
16
|
|
17
|
+
# TODO!: set priority based on date distance to today
|
18
|
+
|
17
19
|
# discard_on Errors::SyncElementJobError
|
18
20
|
# retry_on StandardError, wait: :polynomially_longer
|
19
21
|
|
@@ -26,6 +26,18 @@ module Nexo
|
|
26
26
|
private
|
27
27
|
|
28
28
|
def validate_element_state!
|
29
|
+
if element.synchronizable.blank?
|
30
|
+
raise Errors::SynchronizableNotFound
|
31
|
+
end
|
32
|
+
|
33
|
+
if element.synchronizable.respond_to?(:discarded?) && element.synchronizable.discarded?
|
34
|
+
raise Errors::SynchronizableDiscarded
|
35
|
+
end
|
36
|
+
|
37
|
+
if element.folder.discarded?
|
38
|
+
raise Errors::FolderDiscarded
|
39
|
+
end
|
40
|
+
|
29
41
|
if element.synchronizable.conflicted?
|
30
42
|
raise Errors::ElementConflicted
|
31
43
|
end
|
data/app/lib/nexo/errors.rb
CHANGED
@@ -7,6 +7,8 @@ module Nexo
|
|
7
7
|
class ElementAlreadySynced < Error; end
|
8
8
|
class MoreThanOneElementInFolderForSynchronizable < Error; end
|
9
9
|
class InvalidFolderState < Error; end
|
10
|
+
class FolderDiscarded < Error; end
|
11
|
+
class SynchronizableDiscarded < Error; end
|
10
12
|
|
11
13
|
# on ControllerHelper
|
12
14
|
class InvalidParamsError < Error; end
|
data/app/models/nexo/client.rb
CHANGED
@@ -29,8 +29,7 @@ module Nexo
|
|
29
29
|
enum :service, google: 0
|
30
30
|
enum :tcp_status, authorized: 0, disabled: 1, expired: 2
|
31
31
|
|
32
|
-
validates :service, :
|
33
|
-
:tcp_status, :secret, presence: true
|
32
|
+
validates :service, :tcp_status, :secret, presence: true
|
34
33
|
|
35
34
|
serialize :secret, coder: JSON
|
36
35
|
|
data/db/seeds.rb
CHANGED
@@ -1,3 +1,28 @@
|
|
1
1
|
module Nexo
|
2
|
-
|
2
|
+
ENV.fetch('SEED_GOOGLE_APIS_CLIENT_SECRET', nil) || puts("WARN: env variable SEED_GOOGLE_APIS_CLIENT_SECRET not found")
|
3
|
+
ENV.fetch('SEED_GOOGLE_APIS_TOKEN', nil) || puts("WARN: env variable SEED_GOOGLE_APIS_TOKEN not found")
|
4
|
+
|
5
|
+
if ENV.fetch('SEED_GOOGLE_APIS_CLIENT_SECRET', nil)
|
6
|
+
client = Client.create!(
|
7
|
+
tcp_status: 0,
|
8
|
+
service: "google",
|
9
|
+
secret: JSON.parse(ENV.fetch('SEED_GOOGLE_APIS_CLIENT_SECRET'))
|
10
|
+
)
|
11
|
+
user = User.first
|
12
|
+
integration = Nexo::Integration.create!(
|
13
|
+
user:,
|
14
|
+
client:,
|
15
|
+
name: "Default integration",
|
16
|
+
scope: [ "auth_calendar_app_created" ]
|
17
|
+
)
|
18
|
+
|
19
|
+
if ENV.fetch('SEED_GOOGLE_APIS_TOKEN', nil)
|
20
|
+
Nexo::Token.create!(
|
21
|
+
integration:,
|
22
|
+
secret: ENV.fetch('SEED_GOOGLE_APIS_TOKEN'),
|
23
|
+
tpt_status: :active,
|
24
|
+
environment: "development"
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
3
28
|
end
|
data/lib/nexo/version.rb
CHANGED