Class: QueryGuard::Uploader::Interface

Inherits:
Object
  • Object
show all
Defined in:
lib/query_guard/uploader/interface.rb

Overview

Abstract interface for report uploaders.

All uploaders must implement this interface. This allows:

  • Pluggable upload strategies (no-op, HTTP, webhook, etc.)
  • Easy testing with mock uploaders
  • Future extensibility without changing core code

Example:

uploader = QueryGuard::Uploader.for_config(config)
result = uploader.upload(report_json)

Direct Known Subclasses

HttpUploader, NoOpUploader

Instance Method Summary collapse

Instance Method Details

#name ⇒ String

Human-readable name of this uploader.

Returns:

  • (String)

Raises:

  • (NotImplementedError)


38
39
40
# File 'lib/query_guard/uploader/interface.rb', line 38

def name
  raise NotImplementedError, "#{self.class} must implement #name"
end

#ready? ⇒ Boolean

Check if this uploader is properly configured and ready.

Returns:

  • (Boolean) —

    true if ready to upload, false otherwise

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/query_guard/uploader/interface.rb', line 31

def ready?
  raise NotImplementedError, "#{self.class} must implement #ready?"
end

#status ⇒ Hash

Get status/diagnostic information for logging.

Returns:

  • (Hash) —

    Status information (target_url, enabled, etc.)

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/query_guard/uploader/interface.rb', line 45

def status
  raise NotImplementedError, "#{self.class} must implement #status"
end

#upload(json_report, metadata = {}) ⇒ UploadResult

Upload a JSON report to the configured destination.

Should never raise. Always return an UploadResult with success/failure state.

Parameters:

  • json_report (String) —

    JSON-formatted report string

  • metadata (Hash) (defaults to: {}) —

    Optional metadata (report_id, trace_id, etc.)

Returns:

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/query_guard/uploader/interface.rb', line 24

def upload(json_report,  = {})
  raise NotImplementedError, "#{self.class} must implement #upload"
end