Class: RubyLLM::Providers::GitLab::TokenManager
- Inherits:
-
Object
- Object
- RubyLLM::Providers::GitLab::TokenManager
- Defined in:
- lib/ruby_llm/providers/gitlab/token_manager.rb
Constant Summary collapse
- CACHE_DURATION =
25 minutes
25 * 60
- DEFAULT_INSTANCE_URL =
'https://gitlab.com'- DEFAULT_GATEWAY_URL =
'https://cloud.gitlab.com'- TOKEN_PATH =
'/api/v4/ai/third_party_agents/direct_access'
Instance Method Summary collapse
- #anthropic_base_url ⇒ Object
- #gateway_headers ⇒ Object
-
#initialize(config) ⇒ TokenManager
constructor
A new instance of TokenManager.
- #invalidate! ⇒ Object
- #openai_base_url ⇒ Object
- #token ⇒ Object
Constructor Details
#initialize(config) ⇒ TokenManager
Returns a new instance of TokenManager.
12 13 14 15 16 17 18 |
# File 'lib/ruby_llm/providers/gitlab/token_manager.rb', line 12 def initialize(config) @config = config @mutex = Mutex.new @cached_token = nil @cached_headers = nil @cached_at = nil end |
Instance Method Details
#anthropic_base_url ⇒ Object
38 39 40 |
# File 'lib/ruby_llm/providers/gitlab/token_manager.rb', line 38 def anthropic_base_url "#{gateway_url}/ai/v1/proxy/anthropic" end |
#gateway_headers ⇒ Object
25 26 27 28 |
# File 'lib/ruby_llm/providers/gitlab/token_manager.rb', line 25 def gateway_headers refresh_if_needed @cached_headers end |
#invalidate! ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/ruby_llm/providers/gitlab/token_manager.rb', line 30 def invalidate! @mutex.synchronize do @cached_token = nil @cached_headers = nil @cached_at = nil end end |
#openai_base_url ⇒ Object
42 43 44 |
# File 'lib/ruby_llm/providers/gitlab/token_manager.rb', line 42 def openai_base_url "#{gateway_url}/ai/v1/proxy/openai/v1" end |
#token ⇒ Object
20 21 22 23 |
# File 'lib/ruby_llm/providers/gitlab/token_manager.rb', line 20 def token refresh_if_needed @cached_token end |