lib/github_authentication/provider.rb in github-authentication-1.0.2 vs lib/github_authentication/provider.rb in github-authentication-1.1.0

- old
+ new

@@ -1,29 +1,27 @@ # frozen_string_literal: true -require "mutex_m.rb" -require 'github_authentication/retriable' +require "github_authentication/retriable" module GithubAuthentication class Provider include Retriable - include Mutex_m Error = Class.new(StandardError) TokenGeneratorError = Class.new(Error) def initialize(generator:, cache:) - super() @token = nil @generator = generator @cache = cache + @mutex = Mutex.new end def token(seconds_ttl: 5 * 60) return @token if @token&.valid_for?(seconds_ttl) with_retries(TokenGeneratorError) do - mu_synchronize do + @mutex.synchronize do return @token if @token&.valid_for?(seconds_ttl) if (@token = @cache.read) return @token if @token.valid_for?(seconds_ttl) end