Class: LogStash::Outputs::Application_insights::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/application_insights/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(storage_account_name, force = nil) ⇒ Client

Returns a new instance of Client.



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/logstash/outputs/application_insights/client.rb', line 27

def initialize ( , force = nil )
  @storage_account_name = 
  @storage_account = Clients.instance.( , force )

  @tuple = @storage_account[:clients_Q].pop
  ( @current_storage_account_key_index, @current_azure_storage_auth_sas, @current_azure_storage_client) = @tuple
  if @current_storage_account_key_index != @storage_account[:valid_index]
    @current_storage_account_key_index = @storage_account[:valid_index]
    
    @tuple = [ @current_storage_account_key_index, @current_azure_storage_auth_sas, @current_azure_storage_client ]
  end 
  @storage_account_key_index = @current_storage_account_key_index
end

Instance Method Details

#blobClientObject



56
57
58
59
60
61
62
# File 'lib/logstash/outputs/application_insights/client.rb', line 56

def blobClient
  raise UnexpectedBranchError, "client already disposed" unless @tuple
  @last_client_type = :blobClient
  # breaking change after azure-storage 0.10.1 
  # @current_azure_storage_client.blobClient
  @current_azure_storage_client.blob_client
end

#dispose(io_failed_reason = nil) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/logstash/outputs/application_insights/client.rb', line 41

def dispose ( io_failed_reason = nil )
  if @tuple 
    if  @current_storage_account_key_index == @storage_account_key_index
      @storage_account[:clients_Q] << @tuple
    else
      @storage_account[:valid_index] = @current_storage_account_key_index
      @storage_account[:clients_Q] << [ @current_storage_account_key_index, @current_azure_storage_auth_sas, @current_azure_storage_client ]
    end
    @tuple = nil

    Clients.instance.( @storage_account_name, io_failed_reason ) if io_failed_reason && :blobClient == @last_client_type
  end
  nil
end

#notifyClientObject



72
73
74
75
76
# File 'lib/logstash/outputs/application_insights/client.rb', line 72

def notifyClient
  raise UnexpectedBranchError, "client already disposed" unless @tuple
  @last_client_type = :notifyClient
  @current_azure_storage_client
end

#storage_auth_sasObject



78
79
80
81
# File 'lib/logstash/outputs/application_insights/client.rb', line 78

def storage_auth_sas
  raise UnexpectedBranchError, "client already disposed" unless @tuple
  @current_azure_storage_auth_sas
end

#switch_storage_account_key!Object



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/logstash/outputs/application_insights/client.rb', line 84

def 
  raise UnexpectedBranchError, "client already disposed" unless @tuple
  @current_storage_account_key_index = ( @current_storage_account_key_index + 1 ) % @storage_account[:keys].length
  if @current_storage_account_key_index == @storage_account_key_index
    
    false
  else
    
    true
  end
end

#tableClientObject



64
65
66
67
68
69
70
# File 'lib/logstash/outputs/application_insights/client.rb', line 64

def tableClient
  raise UnexpectedBranchError, "client already disposed" unless @tuple
  @last_client_type = :blobClient
  # breaking change after azure-storage 0.10.1 
  # @current_azure_storage_client.tableClient
  @current_azure_storage_client.table_client
end