Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
63967d47
Commit
63967d47
authored
Oct 01, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add event store for Geo::CacheInvalidationEvent
parent
df714a4e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
+76
-0
ee/app/services/geo/cache_invalidation_event_store.rb
ee/app/services/geo/cache_invalidation_event_store.rb
+31
-0
ee/spec/services/geo/cache_invalidation_event_store_spec.rb
ee/spec/services/geo/cache_invalidation_event_store_spec.rb
+45
-0
No files found.
ee/app/services/geo/cache_invalidation_event_store.rb
0 → 100644
View file @
63967d47
# frozen_string_literal: true
module
Geo
class
CacheInvalidationEventStore
<
EventStore
self
.
event_type
=
:cache_invalidation_event
attr_reader
:key
def
initialize
(
key
)
@key
=
key
end
private
def
build_event
Geo
::
CacheInvalidationEvent
.
new
(
key:
key
)
end
# This is called by ProjectLogHelpers to build json log with context info
#
# @see ::Gitlab::Geo::ProjectLogHelpers
def
base_log_data
(
message
)
{
class:
self
.
class
.
name
,
cache_key:
key
.
to_s
,
job_id:
get_sidekiq_job_id
,
message:
message
}.
compact
end
end
end
ee/spec/services/geo/cache_invalidation_event_store_spec.rb
0 → 100644
View file @
63967d47
# frozen_string_literal: true
require
'spec_helper'
describe
Geo
::
CacheInvalidationEventStore
do
include
EE
::
GeoHelpers
set
(
:secondary_node
)
{
create
(
:geo_node
)
}
let
(
:cache_key
)
{
'cache-key'
}
subject
{
described_class
.
new
(
cache_key
)
}
describe
'#create'
do
it_behaves_like
'a Geo event store'
,
Geo
::
CacheInvalidationEvent
context
'when running on a primary node'
do
before
do
stub_primary_node
end
it
'tracks the cache key that should be invalidated'
do
subject
.
create!
expect
(
Geo
::
CacheInvalidationEvent
.
last
).
to
have_attributes
(
key:
cache_key
)
end
it
'logs an error message when event creation fail'
do
subject
=
described_class
.
new
(
nil
)
expected_message
=
{
class:
described_class
.
name
,
cache_key:
''
,
message:
'Cache invalidation event could not be created'
,
error:
"Validation failed: Key can't be blank"
}
expect
(
Gitlab
::
Geo
::
Logger
).
to
receive
(
:error
)
.
with
(
expected_message
).
and_call_original
subject
.
create!
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment