Class: Webhookdb::Replicator::Fake
Constant Summary
Constants inherited
from Base
Base::MAX_INDEX_NAME_LENGTH
DBAdapter::ColumnTypes::BIGINT, DBAdapter::ColumnTypes::BIGINT_ARRAY, DBAdapter::ColumnTypes::BOOLEAN, DBAdapter::ColumnTypes::COLUMN_TYPES, DBAdapter::ColumnTypes::DATE, DBAdapter::ColumnTypes::DECIMAL, DBAdapter::ColumnTypes::DOUBLE, DBAdapter::ColumnTypes::FLOAT, DBAdapter::ColumnTypes::INTEGER, DBAdapter::ColumnTypes::INTEGER_ARRAY, DBAdapter::ColumnTypes::OBJECT, DBAdapter::ColumnTypes::TEXT, DBAdapter::ColumnTypes::TEXT_ARRAY, DBAdapter::ColumnTypes::TIMESTAMP, DBAdapter::ColumnTypes::UUID
Instance Attribute Summary
Attributes inherited from Base
#service_integration
Class Method Summary
collapse
Instance Method Summary
collapse
attr_predicate, attr_predicate_accessor, singleton_attr_accessor, singleton_attr_reader, singleton_attr_writer, singleton_method_alias, singleton_predicate_accessor, singleton_predicate_reader
Methods inherited from Base
#_any_subscriptions_to_notify?, #_backfill_state_change_fields, #_backfillers, #_clear_backfill_information, #_clear_webook_information, #_coalesce_excluded_on_update, #_enqueue_backfill_jobs, #_extra_index_specs, #_fetch_enrichment, #_find_dependency_candidate, #_notify_dependents, #_parallel_backfill, #_prepare_for_insert, #_publish_rowupsert, #_resource_to_data, #_store_enrichment_body?, #_to_json, #_upsert_update_expr, #_upsert_webhook, #_verify_backfill_err_msg, #_webhook_state_change_fields, #admin_dataset, #backfill, #backfill_not_supported_message, #calculate_and_backfill_state_machine, #calculate_dependency_state_machine_step, #calculate_preferred_create_state_machine, chunked_row_update_bounds, #clear_backfill_information, #clear_webhook_information, #create_table, #create_table_modification, #data_column, #dbadapter_table, #denormalized_columns, #descriptor, #documentation_url, #enqueue_sync_targets, #enrichment_column, #ensure_all_columns, #ensure_all_columns_modification, #find_dependent, #find_dependent!, #indices, #initialize, #on_dependency_webhook_upsert, #preferred_create_state_machine_method, #primary_key_column, #process_state_change, #qualified_table_sequel_identifier, #readonly_dataset, #remote_key_column, #resource_name_plural, #resource_name_singular, #schema_and_table_symbols, #storable_columns, #timestamp_column, #upsert_webhook, #upsert_webhook_body, #verify_backfill_credentials, #webhook_endpoint, #webhook_response
Class Method Details
.descriptor ⇒ Object
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/webhookdb/replicator/fake.rb', line 14
def self.descriptor
return Webhookdb::Replicator::Descriptor.new(
name: "fake_v1",
ctor: ->(sint) { Webhookdb::Replicator::Fake.new(sint) },
feature_roles: ["internal"],
resource_name_singular: "Fake",
supports_webhooks: true,
supports_backfill: true,
)
end
|
.reset ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/webhookdb/replicator/fake.rb', line 25
def self.reset
self.webhook_response = Webhookdb::WebhookResponse.ok
self.upsert_has_deps = false
self.resource_and_event_hook = nil
self.dispatch_request_to_hook = nil
self.process_webhooks_synchronously = nil
self. = []
self.requires_sequence = false
end
|
.stub_backfill_request(items, status: 200) ⇒ Object
35
36
37
38
|
# File 'lib/webhookdb/replicator/fake.rb', line 35
def self.stub_backfill_request(items, status: 200)
return WebMock::API.stub_request(:get, "https://fake-integration/?token=").
to_return(status:, body: [items, nil].to_json, headers: {"Content-Type" => "application/json"})
end
|
Instance Method Details
#_denormalized_columns ⇒ Object
#_fetch_backfill_page(pagination_token, **_kwargs) ⇒ Object
129
130
131
132
133
|
# File 'lib/webhookdb/replicator/fake.rb', line 129
def _fetch_backfill_page(, **_kwargs)
r = Webhookdb::Http.get("https://fake-integration?token=#{}", logger: nil, timeout: 30)
raise "Expected 2-item array" unless r.parsed_response.is_a?(Array) && r.parsed_response.length == 2
return r.parsed_response
end
|
#_remote_key_column ⇒ Object
#_resource_and_event(request) ⇒ Object
111
112
113
114
|
# File 'lib/webhookdb/replicator/fake.rb', line 111
def _resource_and_event(request)
return self.class.resource_and_event_hook.call(request) if self.class.resource_and_event_hook
return request.body, nil
end
|
#_timestamp_column_name ⇒ Object
107
108
109
|
# File 'lib/webhookdb/replicator/fake.rb', line 107
def _timestamp_column_name
return :at
end
|
#_update_where_expr ⇒ Object
116
117
118
|
# File 'lib/webhookdb/replicator/fake.rb', line 116
def _update_where_expr
return Sequel[self.qualified_table_sequel_identifier][:at] < Sequel[:excluded][:at]
end
|
#_webhook_response(_request) ⇒ Object
86
87
88
89
90
|
# File 'lib/webhookdb/replicator/fake.rb', line 86
def _webhook_response(_request)
r = self.class.webhook_response
raise r if r.is_a?(Exception)
return r
end
|
#calculate_backfill_state_machine ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/webhookdb/replicator/fake.rb', line 67
def calculate_backfill_state_machine
step = Webhookdb::Replicator::StateMachineStep.new
unless self.service_integration.backfill_secret.present?
step.needs_input = true
step.output = "Now let's test the backfill flow."
step.prompt = "Paste or type a string here:"
step.prompt_is_secret = false
step.post_to_url = self.service_integration.unauthed_webhook_path + "/transition/backfill_secret"
step.complete = false
return step
end
step.needs_input = false
step.output = "The backfill flow is working correctly."
step.complete = true
return step
end
|
#calculate_webhook_state_machine ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/webhookdb/replicator/fake.rb', line 53
def calculate_webhook_state_machine
step = Webhookdb::Replicator::StateMachineStep.new
unless self.service_integration.webhook_secret.present?
step.output = "You're creating a fake_v1 service integration."
return step.prompting("fake API secret").webhook_secret(self.service_integration)
end
step.output = "The integration creation flow is working correctly. Here is " \
"the integration's opaque id, which you'll need to enter in a second: " \
"#{self.service_integration.opaque_id}"
return step.completed
end
|
#dispatch_request_to(request) ⇒ Object
124
125
126
127
|
# File 'lib/webhookdb/replicator/fake.rb', line 124
def dispatch_request_to(request)
return self.class.dispatch_request_to_hook.call(request) if self.class.dispatch_request_to_hook
return super
end
|
44
45
46
|
# File 'lib/webhookdb/replicator/fake.rb', line 44
def ()
self.class..each { |h| [h] = "***" }
end
|
#process_webhooks_synchronously? ⇒ Boolean
40
41
42
|
# File 'lib/webhookdb/replicator/fake.rb', line 40
def process_webhooks_synchronously?
return self.class.process_webhooks_synchronously ? true : false
end
|
#requires_sequence? ⇒ Boolean
120
121
122
|
# File 'lib/webhookdb/replicator/fake.rb', line 120
def requires_sequence?
return self.class.requires_sequence
end
|
#synchronous_processing_response_body ⇒ Object
48
49
50
51
|
# File 'lib/webhookdb/replicator/fake.rb', line 48
def synchronous_processing_response_body(**)
return super unless self.process_webhooks_synchronously?
return self.class.process_webhooks_synchronously
end
|
#upsert_has_deps? ⇒ Boolean
135
136
137
|
# File 'lib/webhookdb/replicator/fake.rb', line 135
def upsert_has_deps?
return self.class.upsert_has_deps
end
|