Class: Webhookdb::Replicator::FakeExhaustiveConverter

Inherits:
Fake
  • Object
show all
Defined in:
lib/webhookdb/replicator/fake.rb

Constant Summary

Constants inherited from Base

Base::MAX_INDEX_NAME_LENGTH

Constants included from DBAdapter::ColumnTypes

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 collapse

Attributes inherited from Base

#service_integration

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Fake

#_fetch_backfill_page, #_remote_key_column, #_resource_and_event, #_timestamp_column_name, #_update_where_expr, #_webhook_response, #calculate_backfill_state_machine, #calculate_webhook_state_machine, #dispatch_request_to, #preprocess_headers_for_logging, #process_webhooks_synchronously?, reset, stub_backfill_request, #synchronous_processing_response_body, #upsert_has_deps?

Methods included from MethodUtilities

#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, #_remote_key_column, #_resource_and_event, #_resource_to_data, #_store_enrichment_body?, #_timestamp_column_name, #_to_json, #_update_where_expr, #_upsert_update_expr, #_upsert_webhook, #_verify_backfill_err_msg, #_webhook_response, #_webhook_state_change_fields, #admin_dataset, #backfill, #backfill_not_supported_message, #calculate_and_backfill_state_machine, #calculate_backfill_state_machine, #calculate_dependency_state_machine_step, #calculate_preferred_create_state_machine, #calculate_webhook_state_machine, chunked_row_update_bounds, #clear_backfill_information, #clear_webhook_information, #create_table, #create_table_modification, #data_column, #dbadapter_table, #denormalized_columns, #descriptor, #dispatch_request_to, #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, #preprocess_headers_for_logging, #primary_key_column, #process_state_change, #process_webhooks_synchronously?, #qualified_table_sequel_identifier, #readonly_dataset, #remote_key_column, #resource_name_plural, #resource_name_singular, #schema_and_table_symbols, #storable_columns, #synchronous_processing_response_body, #timestamp_column, #upsert_has_deps?, #upsert_webhook, #upsert_webhook_body, #verify_backfill_credentials, #webhook_endpoint, #webhook_response

Constructor Details

This class inherits a constructor from Webhookdb::Replicator::Base

Instance Attribute Details

#exclude_unimplemented_sql_update_colsObject

True to return only the columns that can be used for updates. Used to test column updates. Should be true when testing Ruby converters.



337
338
339
# File 'lib/webhookdb/replicator/fake.rb', line 337

def exclude_unimplemented_sql_update_cols
  @exclude_unimplemented_sql_update_cols
end

#super_cols_onlyObject

True to return only the superclass columns. Used to test column updates.



334
335
336
# File 'lib/webhookdb/replicator/fake.rb', line 334

def super_cols_only
  @super_cols_only
end

Class Method Details

.descriptorObject



320
321
322
323
324
325
326
327
328
329
# File 'lib/webhookdb/replicator/fake.rb', line 320

def self.descriptor
  return Webhookdb::Replicator::Descriptor.new(
    name: "fake_exhaustive_converter_v1",
    ctor: ->(sint) { Webhookdb::Replicator::FakeExhaustiveConverter.new(sint) },
    feature_roles: ["internal"],
    resource_name_singular: "Fake with all converters",
    supports_webhooks: true,
    supports_backfill: false,
  )
end

Instance Method Details

#_denormalized_columnsObject



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/webhookdb/replicator/fake.rb', line 339

def _denormalized_columns
  cols = super
  return cols if self.super_cols_only
  cols += [
    Webhookdb::Replicator::Column.new(
      :comma_sep,
      TEXT_ARRAY,
      converter: Webhookdb::Replicator::Column::CONV_COMMA_SEP,
    ),
    Webhookdb::Replicator::Column.new(
      :geo_lat,
      DECIMAL,
      data_key: "latlng",
      converter: Webhookdb::Replicator::Column.converter_array_element(index: 0, sep: " ", cls: DECIMAL),
    ),
    Webhookdb::Replicator::Column.new(
      :geo_lng,
      DECIMAL,
      data_key: "latlng",
      converter: Webhookdb::Replicator::Column.converter_array_element(index: 1, sep: " ", cls: DECIMAL),
    ),
    Webhookdb::Replicator::Column.new(:date, DATE, converter: :date),
    Webhookdb::Replicator::Column.new(:datetime, TIMESTAMP, converter: :time),
    Webhookdb::Replicator::Column.new(:parsed_int, INTEGER, converter: :to_i),
    Webhookdb::Replicator::Column.new(:unix_ts, TIMESTAMP, converter: :tsat),
    Webhookdb::Replicator::Column.new(
      :strptime,
      TIMESTAMP,
      converter: Webhookdb::Replicator::Column.converter_strptime("%d%m%Y %H%M%S%Z", "DDMMYYYY HH24MISS", cls: Time),
    ),
    Webhookdb::Replicator::Column.new(
      :strptime_date,
      DATE,
      converter: Webhookdb::Replicator::Column.converter_strptime("%d%Y%m", "DDYYYYMM", cls: Date),
    ),
    Webhookdb::Replicator::Column.new(
      :int_array,
      BIGINT_ARRAY,
      data_key: "obj_array",
      converter: Webhookdb::Replicator::Column.converter_array_pluck("id", BIGINT),
    ),
    Webhookdb::Replicator::Column.new(
      :text_array,
      TEXT_ARRAY,
      data_key: "obj_array",
      converter: Webhookdb::Replicator::Column.converter_array_pluck("name", TEXT),
    ),
    Webhookdb::Replicator::Column.new(
      :subtext,
      TEXT,
      converter: Webhookdb::Replicator::Column.converter_gsub("^hello", "goodbye"),
    ),
    Webhookdb::Replicator::Column.new(
      :regex_extract,
      TEXT,
      data_key: "regex_conv",
      converter: Webhookdb::Replicator::Column.converter_from_regex('/resources/(\d+)'),
    ),
    Webhookdb::Replicator::Column.new(
      :regex_conv,
      INTEGER,
      converter: Webhookdb::Replicator::Column.converter_from_regex('/resources/(\d+)', dbtype: INTEGER),
    ),
    Webhookdb::Replicator::Column.new(
      :to_utc_date,
      DATE,
      converter: Webhookdb::Replicator::Column::CONV_TO_UTC_DATE,
    ),
    Webhookdb::Replicator::Column.new(
      :using_backfill_expr,
      TEXT,
      data_key: "my_id",
      backfill_expr: "hi there",
    ),
    Webhookdb::Replicator::Column.new(
      :using_backfill_statement,
      TEXT,
      data_key: "my_id",
      backfill_statement: Sequel.lit(<<~SQL),
        CREATE OR REPLACE FUNCTION pg_temp.fake_backfiller_update_tests(text)
          RETURNS text AS 'SELECT $1 || $1' LANGUAGE sql IMMUTABLE
      SQL
      backfill_expr: Sequel.lit("pg_temp.fake_backfiller_update_tests(my_id)"),
    ),
  ]
  return cols if self.exclude_unimplemented_sql_update_cols
  cols << Webhookdb::Replicator::Column.new(
    :int_or_seq_has,
    INTEGER,
    converter: Webhookdb::Replicator::Column.converter_int_or_sequence_from_regex('/resources/(\d+)'),
  )
  cols << Webhookdb::Replicator::Column.new(
    :int_or_seq_has_not,
    INTEGER,
    converter: Webhookdb::Replicator::Column.converter_int_or_sequence_from_regex('/resources/(\d+)'),
  )
  cols << Webhookdb::Replicator::Column.new(
    :map_lookup,
    TEXT,
    converter: Webhookdb::Replicator::Column.converter_map_lookup(
      array: false,
      map: {"a" => "A", "b" => "B"},
    ),
  )
  cols << Webhookdb::Replicator::Column.new(
    :map_lookup_array,
    TEXT_ARRAY,
    converter: Webhookdb::Replicator::Column.converter_map_lookup(
      array: true,
      map: {"a" => "A", "b" => "B"},
    ),
  )
  return cols
end

#requires_sequence?Boolean

Returns:

  • (Boolean)


331
# File 'lib/webhookdb/replicator/fake.rb', line 331

def requires_sequence? = true