Documentation
¶
Index ¶
- Variables
- func GenerateID(prefix string) string
- type ArcInstance
- type ArcInstanceStore
- func (s *ArcInstanceStore) Count(ctx context.Context) (int, error)
- func (s *ArcInstanceStore) Create(ctx context.Context, inst *ArcInstance) error
- func (s *ArcInstanceStore) Delete(ctx context.Context, orgID string) error
- func (s *ArcInstanceStore) GetByOrg(ctx context.Context, orgID string) (*ArcInstance, error)
- func (s *ArcInstanceStore) List(ctx context.Context) ([]*ArcInstance, error)
- func (s *ArcInstanceStore) Update(ctx context.Context, inst *ArcInstance) error
- type DB
Constants ¶
This section is empty.
Variables ¶
var ErrArcInstanceNotFound = errors.New("arc instance not found")
ErrArcInstanceNotFound is returned when no arc_instances row matches the lookup.
Functions ¶
func GenerateID ¶
GenerateID creates a prefixed random ID (e.g., "org_a1b2c3d4")
Types ¶
type ArcInstance ¶
type ArcInstance struct {
ID string
OrgID string
URL string
APIKey string
Database string
Measurement string
CreatedAt time.Time
UpdatedAt time.Time
}
ArcInstance describes the per-org Arc connection. APIKey is plaintext and is only populated by Get* methods (after decryption); Create/Update consume it, encrypt, and discard.
type ArcInstanceStore ¶
type ArcInstanceStore struct {
// contains filtered or unexported fields
}
ArcInstanceStore wraps the arc_instances table with envelope encryption for the API key column.
func NewArcInstanceStore ¶
func NewArcInstanceStore(db *sql.DB, cipher *crypto.Cipher) *ArcInstanceStore
NewArcInstanceStore returns a store using the supplied DB handle and cipher.
func (*ArcInstanceStore) Count ¶
func (s *ArcInstanceStore) Count(ctx context.Context) (int, error)
Count returns the total number of configured arc instances. Used by auto-migration to detect a fresh install.
func (*ArcInstanceStore) Create ¶
func (s *ArcInstanceStore) Create(ctx context.Context, inst *ArcInstance) error
Create inserts a new arc instance, encrypting the API key before write.
func (*ArcInstanceStore) Delete ¶
func (s *ArcInstanceStore) Delete(ctx context.Context, orgID string) error
Delete removes the arc_instances row for an org. Returns ErrArcInstanceNotFound if no row matched.
func (*ArcInstanceStore) GetByOrg ¶
func (s *ArcInstanceStore) GetByOrg(ctx context.Context, orgID string) (*ArcInstance, error)
GetByOrg returns the (decrypted) Arc instance for an org or ErrArcInstanceNotFound if none is configured.
func (*ArcInstanceStore) List ¶
func (s *ArcInstanceStore) List(ctx context.Context) ([]*ArcInstance, error)
List returns every configured instance, with API keys decrypted.
func (*ArcInstanceStore) Update ¶
func (s *ArcInstanceStore) Update(ctx context.Context, inst *ArcInstance) error
Update replaces the URL, API key, database, and measurement for an existing instance keyed by org_id.