Class: Outhad::Integrations::Destination::PineconeDB::Client

Inherits:
DestinationConnector
  • Object
show all
Defined in:
lib/outhad/integrations/destination/pinecone_db/client.rb

Instance Method Summary collapse

Instance Method Details

#check_connection(connection_config) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/outhad/integrations/destination/pinecone_db/client.rb', line 12

def check_connection(connection_config)
  connection_config = connection_config.with_indifferent_access
  create_connection(connection_config)
  result = @pinecone.describe_index(@index_name)
  if result
    success_status
  else
    failure_status(nil)
  end
rescue StandardError => e
  handle_exception(e, { context: "PINECONE:CHECK_CONNECTION:EXCEPTION", type: "error" })
  failure_status(e)
end

#discover(connection_config) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/outhad/integrations/destination/pinecone_db/client.rb', line 26

def discover(connection_config)
  connection_config = connection_config.with_indifferent_access
  create_connection(connection_config)
  pinecone_index = @pinecone.index(@index_name)
  response = pinecone_index.describe_index_stats
  results = JSON.parse(response.body)
  records = results["namespaces"].keys
  catalog = Catalog.new(streams: create_streams(records))
  catalog.to_outhad_message
rescue StandardError => e
  handle_exception(e, {
                     context: "PINECONE:DISCOVER:EXCEPTION",
                     type: "error"
                   })
end

#write(sync_config, records, _action = "upsert") ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/outhad/integrations/destination/pinecone_db/client.rb', line 42

def write(sync_config, records, _action = "upsert")
  @sync_config = sync_config
  connection_config = sync_config.destination.connection_specification.with_indifferent_access
  create_connection(connection_config)
  process_records(records, sync_config.stream)
rescue StandardError => e
  handle_exception(e, {
                     context: "PINECONE:WRITE:EXCEPTION",
                     type: "error",
                     sync_id: @sync_config.sync_id,
                     sync_run_id: @sync_config.sync_run_id
                   })
end