Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 31 additions & 28 deletions lib/fbe/fb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,37 @@ def Fbe.fb(fb: $fb, global: $global, options: $options, loog: $loog)
raise(Fbe::Error, 'The $global is not set') if global.nil?
raise(Fbe::Error, 'The $options is not set') if options.nil?
raise(Fbe::Error, 'The $loog is not set') if loog.nil?
global[:fb] ||=
begin
rules = Dir.glob(File.join(File.join(__dir__, '../../rules'), '*.fe')).map { |f| File.read(f) }
fbe = Factbase::Rules.new(
fb,
"(and \n#{rules.join("\n")}\n)",
uid: '_id'
)
fbe =
Factbase::Pre.new(fbe) do |f, fbt|
max = fbt.query('(max _id)').one
f._id = (max.nil? ? 0 : max) + 1
f._time = Time.now
f._version = [Factbase::VERSION, Judges::VERSION, options.action_version].compact.join('/')
f._job = Integer(options.job_id.to_s, 10) if options.job_id
end
Factbase::Impatient.new(
Factbase::Logged.new(
Factbase::SyncFactbase.new(
Factbase::IndexedFactbase.new(
Factbase::CachedFactbase.new(
fbe
global[:mutex] ||= Mutex.new
global[:mutex].synchronize do
global[:fb] ||=
begin
rules = Dir.glob(File.join(File.join(__dir__, '../../rules'), '*.fe')).map { |f| File.read(f) }
fbe = Factbase::Rules.new(
fb,
"(and \n#{rules.join("\n")}\n)",
uid: '_id'
)
fbe =
Factbase::Pre.new(fbe) do |f, fbt|
max = fbt.query('(max _id)').one
f._id = (max.nil? ? 0 : max) + 1
f._time = Time.now
f._version = [Factbase::VERSION, Judges::VERSION, options.action_version].compact.join('/')
f._job = Integer(options.job_id.to_s, 10) if options.job_id
end
Factbase::Impatient.new(
Factbase::Logged.new(
Factbase::SyncFactbase.new(
Factbase::IndexedFactbase.new(
Factbase::CachedFactbase.new(
fbe
)
)
)
),
loog
),
loog
),
timeout: 60
)
end
timeout: 60
)
end
end
end
17 changes: 10 additions & 7 deletions lib/fbe/github_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
# @param [Loog] loog Logging facility
# @return [Fbe::Graph] The instance of the class
def Fbe.github_graph(options: $options, global: $global, loog: $loog)
global[:github_graph] ||=
if options.testing.nil?
Fbe::Graph.new(token: options.github_token || ENV.fetch('GITHUB_TOKEN', nil))
else
loog.debug('The connection to GitHub GraphQL API is mocked')
Fbe::Graph::Fake.new
end
global[:mutex] ||= Mutex.new
global[:mutex].synchronize do
global[:github_graph] ||=
if options.testing.nil?
Fbe::Graph.new(token: options.github_token || ENV.fetch('GITHUB_TOKEN', nil))
else
loog.debug('The connection to GitHub GraphQL API is mocked')
Fbe::Graph::Fake.new
end
end
end

# A client to GitHub GraphQL.
Expand Down
Loading
Loading