// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.29.0

package lrdb

import (
	"database/sql/driver"
	"fmt"
	"time"

	"github.com/google/uuid"
	"github.com/jackc/pgx/v5/pgtype"
)

type ActionEnum string

const (
	ActionEnumCompact ActionEnum = "compact"
	ActionEnumRollup  ActionEnum = "rollup"
)

func (e *ActionEnum) Scan(src interface{}) error {
	switch s := src.(type) {
	case []byte:
		*e = ActionEnum(s)
	case string:
		*e = ActionEnum(s)
	default:
		return fmt.Errorf("unsupported scan type for ActionEnum: %T", src)
	}
	return nil
}

type NullActionEnum struct {
	ActionEnum ActionEnum `json:"action_enum"`
	Valid      bool       `json:"valid"` // Valid is true if ActionEnum is not NULL
}

// Scan implements the Scanner interface.
func (ns *NullActionEnum) Scan(value interface{}) error {
	if value == nil {
		ns.ActionEnum, ns.Valid = "", false
		return nil
	}
	ns.Valid = true
	return ns.ActionEnum.Scan(value)
}

// Value implements the driver Valuer interface.
func (ns NullActionEnum) Value() (driver.Value, error) {
	if !ns.Valid {
		return nil, nil
	}
	return string(ns.ActionEnum), nil
}

type SignalEnum string

const (
	SignalEnumLogs    SignalEnum = "logs"
	SignalEnumMetrics SignalEnum = "metrics"
	SignalEnumTraces  SignalEnum = "traces"
)

func (e *SignalEnum) Scan(src interface{}) error {
	switch s := src.(type) {
	case []byte:
		*e = SignalEnum(s)
	case string:
		*e = SignalEnum(s)
	default:
		return fmt.Errorf("unsupported scan type for SignalEnum: %T", src)
	}
	return nil
}

type NullSignalEnum struct {
	SignalEnum SignalEnum `json:"signal_enum"`
	Valid      bool       `json:"valid"` // Valid is true if SignalEnum is not NULL
}

// Scan implements the Scanner interface.
func (ns *NullSignalEnum) Scan(value interface{}) error {
	if value == nil {
		ns.SignalEnum, ns.Valid = "", false
		return nil
	}
	ns.Valid = true
	return ns.SignalEnum.Scan(value)
}

// Value implements the driver Valuer interface.
func (ns NullSignalEnum) Value() (driver.Value, error) {
	if !ns.Valid {
		return nil, nil
	}
	return string(ns.SignalEnum), nil
}

type KafkaOffsetTracker struct {
	ID            int64     `json:"id"`
	ConsumerGroup string    `json:"consumer_group"`
	Topic         string    `json:"topic"`
	PartitionID   int32     `json:"partition_id"`
	MinOffset     int64     `json:"min_offset"`
	MaxOffset     int64     `json:"max_offset"`
	Offsets       []int64   `json:"offsets"`
	CreatedAt     time.Time `json:"created_at"`
}

type LogSeg struct {
	OrganizationID uuid.UUID                 `json:"organization_id"`
	Dateint        int32                     `json:"dateint"`
	SegmentID      int64                     `json:"segment_id"`
	InstanceNum    int16                     `json:"instance_num"`
	Fingerprints   []int64                   `json:"fingerprints"`
	RecordCount    int64                     `json:"record_count"`
	FileSize       int64                     `json:"file_size"`
	IngestDateint  int32                     `json:"ingest_dateint"`
	TsRange        pgtype.Range[pgtype.Int8] `json:"ts_range"`
	CreatedBy      CreatedBy                 `json:"created_by"`
	CreatedAt      time.Time                 `json:"created_at"`
	Compacted      bool                      `json:"compacted"`
	Published      bool                      `json:"published"`
	LabelNameMap   []byte                    `json:"label_name_map"`
}

type LrdbExemplarLog struct {
	CreatedAt           time.Time      `json:"created_at"`
	UpdatedAt           time.Time      `json:"updated_at"`
	OrganizationID      uuid.UUID      `json:"organization_id"`
	ServiceIdentifierID uuid.UUID      `json:"service_identifier_id"`
	Exemplar            map[string]any `json:"exemplar"`
	Fingerprint         int64          `json:"fingerprint"`
	RelatedFingerprints []int64        `json:"related_fingerprints"`
	Source              ExemplarSource `json:"source"`
}

type LrdbExemplarMetric struct {
	CreatedAt           time.Time      `json:"created_at"`
	UpdatedAt           time.Time      `json:"updated_at"`
	OrganizationID      uuid.UUID      `json:"organization_id"`
	ServiceIdentifierID uuid.UUID      `json:"service_identifier_id"`
	Exemplar            map[string]any `json:"exemplar"`
	MetricName          string         `json:"metric_name"`
	MetricType          string         `json:"metric_type"`
	Source              ExemplarSource `json:"source"`
}

type LrdbExemplarTrace struct {
	CreatedAt           time.Time      `json:"created_at"`
	UpdatedAt           time.Time      `json:"updated_at"`
	OrganizationID      uuid.UUID      `json:"organization_id"`
	ServiceIdentifierID uuid.UUID      `json:"service_identifier_id"`
	Exemplar            map[string]any `json:"exemplar"`
	Fingerprint         int64          `json:"fingerprint"`
	SpanName            string         `json:"span_name"`
	SpanKind            int32          `json:"span_kind"`
	Source              ExemplarSource `json:"source"`
}

type LrdbServiceIdentifier struct {
	ID             uuid.UUID   `json:"id"`
	CreatedAt      time.Time   `json:"created_at"`
	UpdatedAt      time.Time   `json:"updated_at"`
	OrganizationID pgtype.UUID `json:"organization_id"`
	ServiceName    *string     `json:"service_name"`
	ClusterName    *string     `json:"cluster_name"`
	Namespace      *string     `json:"namespace"`
}

type MetricSeg struct {
	OrganizationID uuid.UUID                 `json:"organization_id"`
	Dateint        int32                     `json:"dateint"`
	FrequencyMs    int32                     `json:"frequency_ms"`
	SegmentID      int64                     `json:"segment_id"`
	InstanceNum    int16                     `json:"instance_num"`
	TsRange        pgtype.Range[pgtype.Int8] `json:"ts_range"`
	RecordCount    int64                     `json:"record_count"`
	FileSize       int64                     `json:"file_size"`
	IngestDateint  int32                     `json:"ingest_dateint"`
	Published      bool                      `json:"published"`
	Rolledup       bool                      `json:"rolledup"`
	CreatedAt      time.Time                 `json:"created_at"`
	CreatedBy      CreatedBy                 `json:"created_by"`
	Fingerprints   []int64                   `json:"fingerprints"`
	SortVersion    int16                     `json:"sort_version"`
	Compacted      bool                      `json:"compacted"`
	LabelNameMap   []byte                    `json:"label_name_map"`
}

type PackEstimate struct {
	OrganizationID uuid.UUID `json:"organization_id"`
	FrequencyMs    int32     `json:"frequency_ms"`
	TargetRecords  *int64    `json:"target_records"`
	UpdatedAt      time.Time `json:"updated_at"`
	Signal         string    `json:"signal"`
}

type PubsubMessageHistory struct {
	Bucket     string    `json:"bucket"`
	ObjectID   string    `json:"object_id"`
	Source     string    `json:"source"`
	ReceivedAt time.Time `json:"received_at"`
}

type TraceSeg struct {
	OrganizationID uuid.UUID                 `json:"organization_id"`
	Dateint        int32                     `json:"dateint"`
	SegmentID      int64                     `json:"segment_id"`
	InstanceNum    int16                     `json:"instance_num"`
	Fingerprints   []int64                   `json:"fingerprints"`
	RecordCount    int64                     `json:"record_count"`
	FileSize       int64                     `json:"file_size"`
	IngestDateint  int32                     `json:"ingest_dateint"`
	TsRange        pgtype.Range[pgtype.Int8] `json:"ts_range"`
	CreatedBy      CreatedBy                 `json:"created_by"`
	CreatedAt      time.Time                 `json:"created_at"`
	Compacted      bool                      `json:"compacted"`
	Published      bool                      `json:"published"`
	LabelNameMap   []byte                    `json:"label_name_map"`
}
