Module: Journaled

Defined in:
app/models/journaled/audit_log/event.rb,
lib/journaled.rb,
lib/journaled/engine.rb,
lib/journaled/errors.rb,
lib/journaled/current.rb,
lib/journaled/version.rb,
lib/journaled/audit_log.rb,
lib/journaled/connection.rb,
lib/journaled/outbox/worker.rb,
lib/journaled/outbox/adapter.rb,
lib/journaled/transaction_ext.rb,
lib/journaled/delivery_adapter.rb,
app/jobs/journaled/delivery_job.rb,
app/models/journaled/outbox/event.rb,
app/jobs/journaled/application_job.rb,
lib/journaled/kinesis_batch_sender.rb,
lib/journaled/kinesis_failed_event.rb,
lib/journaled/outbox/metric_emitter.rb,
lib/journaled/kinesis_client_factory.rb,
lib/journaled/outbox/batch_processor.rb,
lib/journaled/kinesis_sequential_sender.rb,
lib/journaled/delivery_adapters/active_job_adapter.rb

Overview

FIXME: This cannot be included in lib/ because Journaled::Event is autoloaded via app/models

Autoloading Journaled::Event isn't strictly necessary, and for compatibility it would
make sense to move it to lib/.

Defined Under Namespace

Modules: Actor, AuditLog, Changes, Connection, DeliveryAdapters, Event, Outbox, RelationChangeProtection, TransactionExt Classes: ActorUriProvider, ApplicationJob, Change, ChangeDefinition, ChangeWriter, Current, DeliveryAdapter, DeliveryJob, Engine, KinesisBatchSender, KinesisClientFactory, KinesisFailedEvent, KinesisSequentialSender, NotTrulyExceptionalError, TransactionSafetyError, Writer

Constant Summary collapse

SUPPORTED_QUEUE_ADAPTERS =
%w(delayed delayed_job good_job que).freeze
VERSION =
"6.2.3"

Class Method Summary collapse

Class Method Details

.actor_uriObject



68
69
70
# File 'lib/journaled.rb', line 68

def self.actor_uri
  Journaled::ActorUriProvider.instance.actor_uri
end

.commit_hashObject



64
65
66
# File 'lib/journaled.rb', line 64

def self.commit_hash
  ENV.fetch('GIT_COMMIT')
end

.development_or_test?Boolean



52
53
54
# File 'lib/journaled.rb', line 52

def self.development_or_test?
  %w(development test).include?(Rails.env)
end

.enabled?Boolean



56
57
58
# File 'lib/journaled.rb', line 56

def self.enabled?
  ['0', 'false', false, 'f', ''].exclude?(ENV.fetch('JOURNALED_ENABLED', !development_or_test?))
end

.queue_adapterObject



72
73
74
# File 'lib/journaled.rb', line 72

def self.queue_adapter
  job_base_class_name.constantize.queue_adapter_name
end

.schema_providersObject



60
61
62
# File 'lib/journaled.rb', line 60

def self.schema_providers
  @schema_providers ||= [Journaled::Engine, Rails]
end

.tag!(**tags) ⇒ Object



84
85
86
# File 'lib/journaled.rb', line 84

def self.tag!(**tags)
  Current.tags = Current.tags.merge(tags)
end

.tagged(**tags) ⇒ Object



76
77
78
79
80
81
82
# File 'lib/journaled.rb', line 76

def self.tagged(**tags)
  existing_tags = Current.tags
  tag!(**tags)
  yield
ensure
  Current.tags = existing_tags
end

.transactional_batching_enabled?Boolean



40
41
42
# File 'lib/journaled.rb', line 40

def self.transactional_batching_enabled?
  Thread.current[:journaled_transactional_batching_enabled] || @@transactional_batching_enabled
end

.with_transactional_batchingObject



44
45
46
47
48
49
50
# File 'lib/journaled.rb', line 44

def self.with_transactional_batching
  value_was = Thread.current[:journaled_transactional_batching_enabled]
  Thread.current[:journaled_transactional_batching_enabled] = true
  yield
ensure
  Thread.current[:journaled_transactional_batching_enabled] = value_was
end