sql

package
v0.0.0-...-21c0a40 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sql implements a persistent SQL data store. It implements the RegistrationStorer interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	RegistrationTable  string
	RegistrationFields RegistrationFields
	DeploymentTable    string
	DeploymentFields   DeploymentFields
}

Config represents the table and field names necessary for storing/retrieving registrations and deployments within the database.

func NewConfig

func NewConfig() Config

NewConfig returns a new configuration struct with default table and field names for the SQL database.

type DeploymentFields

type DeploymentFields struct {
	Issuer       string
	DeploymentID string
}

DeploymentFields provides the database column names for fields in the datastore.Deployment structure.

type RegistrationFields

type RegistrationFields struct {
	Issuer        string
	ClientID      string
	AuthTokenURI  string
	AuthLoginURI  string
	KeysetURI     string
	TargetLinkURI string
}

RegistrationFields provides the database column names for fields in the datastore.Registration structure.

type Store

type Store struct {
	*sql.DB
	// contains filtered or unexported fields
}

Store implements a persistent SQL-based datastore.

func New

func New(database *sql.DB, config Config) *Store

New returns a Store that satisifes the datastore.RegistrationStorer and datastore.DeploymentStorer interfaces.

func (*Store) FindDeployment

func (s *Store) FindDeployment(issuer, deploymentID string) (datastore.Deployment, error)

FindDeployment looks up and returns either a Deployment by the issuer and deployment ID or the datastore error ErrDeploymentNotFound.

func (*Store) FindRegistrationByIssuerAndClientID

func (s *Store) FindRegistrationByIssuerAndClientID(issuer, clientID string) (datastore.Registration, error)

FindRegistrationByIssuerAndClientID retrieves a registration from the SQL database.

func (*Store) StoreDeployment

func (s *Store) StoreDeployment(issuer string, d datastore.Deployment) error

StoreDeployment stores a deployment in the SQL database.

func (*Store) StoreRegistration

func (s *Store) StoreRegistration(reg datastore.Registration) error

StoreRegistration stores a registration in the SQL database.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL