lib/jamf/api/connection.rb
# creates a thread that loops forever, sleeping most of the time, but
# waking up every 60 seconds to see if the token is expiring in the
# next @token_refresh seconds.
#
# If so, the token is refreshed, and we keep looping and sleeping.
#
# Sets @keep_alive_thread to the Thread object
#
# @return [void]
#
creates a thread that loops forever, sleeping most of the time, but
waking up every 60 seconds to see if the token is expiring in the
next @token_refresh seconds.

If so, the token is refreshed, and we keep looping and sleeping.

Sets @keep_alive_thread to the Thread object
creates a thread that loops forever sleeping most of the time but waking up every 60 seconds to see if the token is expiring in the next @token_refresh seconds . If so the token is refreshed and we keep looping and sleeping . Sets @keep_alive_thread to the Thread object
def start_keep_alive
      return if @keep_alive_thread
      raise 'Token expired' if @token.expired?
      @keep_alive_thread =
        Thread.new do
          loop do
            sleep 60
            begin
              next if @token.secs_remaining > @token_refresh
              @token.refresh @pw
              @rest_cnx.headers[:authorization] = @token.auth_token
            rescue
              next
            end
          end 
        end 
    end
def start_keep_alive return if @keep_alive_thread raise 'Token expired' if @token . expired? @keep_alive_thread = Thread . new do loop do sleep 60 begin next if @token . secs_remaining > @token_refresh @token . refresh @pw @rest_cnx . headers [ :authorization ] = @token . auth_token rescue next end end end end
creates a thread that loops forever, sleeping most of the time, but
waking up every 60 seconds to see if the token is expiring in the
next @token_refresh seconds.
creates a thread that loops forever sleeping most of the time but waking up every 60 seconds to see if the token is expiring in the next @token_refresh seconds .
# make sure faraday uses the new token # TODO: Some kind of error reporting # loop # thread
None
void