-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
554 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
module Karafka | ||
module Web | ||
module Tracking | ||
module Contracts | ||
# Base for all the metric related contracts | ||
class Base < ::Karafka::Core::Contractable::Contract | ||
class << self | ||
# This layer is not for users extensive feedback, thus we can easily use the minimum | ||
# error messaging there is. | ||
def configure | ||
super do |config| | ||
config.error_messages = YAML.safe_load( | ||
File.read( | ||
File.join(Karafka::Web.gem_root, 'config', 'locales', 'errors.yml') | ||
) | ||
).fetch('en').fetch('validations').fetch('web') | ||
end | ||
end | ||
end | ||
|
||
# @param data [Hash] data for validation | ||
# @return [Boolean] true if all good | ||
# @raise [Errors::ContractError] invalid report | ||
def validate!(data) | ||
super(data, Errors::Tracking::ContractError) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module Karafka | ||
module Web | ||
module Tracking | ||
module Contracts | ||
# Contract for error reporting | ||
# Since producers and consumers report their errors to the same topic, we need to have | ||
# a unified contract for both | ||
class Error < Base | ||
configure | ||
|
||
required(:schema_version) { |val| val.is_a?(String) } | ||
required(:type) { |val| val.is_a?(String) && !val.empty? } | ||
required(:error_class) { |val| val.is_a?(String) && !val.empty? } | ||
required(:error_message) { |val| val.is_a?(String) } | ||
required(:backtrace) { |val| val.is_a?(String) } | ||
required(:details) { |val| val.is_a?(Hash) } | ||
required(:occurred_at) { |val| val.is_a?(Float) } | ||
|
||
nested(:process) do | ||
required(:name) { |val| val.is_a?(String) && !val.empty? } | ||
# Tags may not be present for producers because they may operate from outside of | ||
# karafka taggable process | ||
optional(:tags) { |val| val.is_a?(Karafka::Core::Taggable::Tags) } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.