record

package
v0.0.0-...-41b1600 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 4 Imported by: 0

README

#Record design decisions

#####Overall goal: APIs/handlers should not care about what a record's version. Ideally, records will be of the latest version, but it's not guaranteed to be as such and so should be updatable by any versioned handler with its respective inputs and behaviour. It is up to the record to be able to ingest this requirement and be writable in the latest version format.

####Definition: type Record interface { GetFields() logrus.Fields ToASBinSlice() []*aerospike.Bin ToRecordViewV1() RecordViewV1 AddUserCredentialsV1([]common.GrafanaUserV1, []common.ConfluenceServerUserV1) }

GetFields - Get logrus fields for debug logging in tests

ToASBinSlice - Convert record into an Aerospike-compliant format so that it can be easily stored by the record writer (record.writer)

ToRecordViewV1 - Converts a record to a view used to display record information by v1 handlers

AddUserCredentialsV1 - Updates a record's credentials to include set of IDs defined by a v1 credentials handler

####Conventions going forward:

  • Whenever a record is handled, and is determined to be of a non-latest version, then invoke the database writer to rewrite it in the latest form. Old records should only exist when that particular record is inactive and is not being handled.
  • Records should be scheduled to naturally expire so that at some point, inactive records will be pruned and older deprecated endpoints can be removed
  • When a new record version is created, previous record versions (ie RecordV1) should be convertable via an interface method to the latest version. This will be invoked and by the record writer so that we are always writing in the latest format.

Documentation

Index

Constants

View Source
const (
	GrafanaAPIUsersBMKey    = "GrafanaAPIUsers"
	ConfluenceAPIUsersBMKey = "ConfluenceServerAPIUsers"
)
View Source
const (
	MetadataBinName    = "Metadata"
	AccountBinName     = "Account"
	CredentialsBinName = "Credentials"
	VersionAttrName    = "Version"

	GrafanaAPIUserNamespace            = "GrafanaAPIUser"
	ConfluenceServerBasicUserNamespace = "ConfluenceServerBasicUser"
)
View Source
const (
	VersionLevel_1 = "1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountV1

type AccountV1 struct {
	Email string
	Alias string
}

Owner - Creation account details for grouping/fetch

func (AccountV1) GetFields

func (a AccountV1) GetFields() logrus.Fields

type AccountViewV1

type AccountViewV1 struct {
	Email string `json:"Email"`
	Alias string `json:"Alias,omitempty"` //Optional arg. Won't be returned if missing.
}

AccountViewV1 - Creation account details

func (AccountViewV1) GetFields

func (a AccountViewV1) GetFields() logrus.Fields

func (AccountViewV1) IsValid

func (a AccountViewV1) IsValid() (bool, error)

IsValid - returns true if model is valid. Returns false if invalid and includes a non-nil error

type Basic

type Basic struct {
	Username string
	Password string
}

func (Basic) GetFields

func (a Basic) GetFields() logrus.Fields

type BearerToken

type BearerToken struct {
	Token string
}

func (BearerToken) GetFields

func (a BearerToken) GetFields() logrus.Fields

type ConfluenceServerUser

type ConfluenceServerUser struct {
	Auth        common.Auth
	Host        string
	Port        int
	Description string
}

type CredentialsV1

type CredentialsV1 struct {
	GrafanaAPIUsers          map[string]common.GrafanaUserV1
	ConfluenceServerAPIUsers map[string]common.ConfluenceServerUserV1
}

CredentialsV1 - CredentialsV1 for various graph and storage services

func (CredentialsV1) GetFields

func (c CredentialsV1) GetFields() logrus.Fields

type CredentialsView1

type CredentialsView1 struct {
	GrafanaAPIUsers       map[string]GrafanaAPIUser       `json:"GrafanaAPIUsers"`
	ConfluenceServerUsers map[string]ConfluenceServerUser `json:"ConfluenceServerUser"`
}

Credentials - Credentials for various graph and storage services

type DBAuth

type DBAuth struct {
	Basic       Basic
	BearerToken BearerToken
}

DbAuth

func (DBAuth) GetFields

func (a DBAuth) GetFields() logrus.Fields

type GrafanaAPIUser

type GrafanaAPIUser struct {
	Auth        common.Auth
	Host        string
	Port        int
	Description string
}

GrafanaAPIUser - Grafana user without API key information

type MetadataV1

type MetadataV1 struct {
	PrimaryKey string
	LastUpdate string
	CreateTime string
	Version    string
}

MetadataV1 - Record metadata

func (MetadataV1) GetFields

func (m MetadataV1) GetFields() logrus.Fields

type MetadataViewV1

type MetadataViewV1 struct {
	PrimaryKey    string `json:"PrimaryKey"`
	LastUpdate    string `json:"LastUpdate"`
	CreateTimeUTC string `json:"CreateTimeUTC"`
	Version       string `json:"Version"`
}

MetadataViewV1 - Record metadata

type Record

type Record interface {
	//GetFields - returns logrus fields for logging
	GetFields() logrus.Fields
	//ToASBinSlice - converts record to bin map. Used to write record to db in the latest record format
	ToASBinSlice() []*aerospike.Bin
	//ToRecordViewV1 - converts to v1 record view
	ToRecordViewV1() RecordViewV1
	//SetUserCredentialsV1 - Adds input credentials to record. Does not overwrite any existing records
	SetUserCredentialsV1(*logrus.Logger, map[string]common.GrafanaUserV1, map[string]common.ConfluenceServerUserV1)
}

type RecordV1

type RecordV1 struct {
	Metadata    MetadataV1    `json:"Metadata"`
	Account     AccountV1     `json:"Account"`
	Credentials CredentialsV1 `json:"Credentials"`
}

Record - Aerospike configuration + credentials data

func (*RecordV1) GetFields

func (r *RecordV1) GetFields() logrus.Fields

func (*RecordV1) SetUserCredentialsV1

func (r *RecordV1) SetUserCredentialsV1(logger *logrus.Logger, grafanaUsers map[string]common.GrafanaUserV1, confluenceUsers map[string]common.ConfluenceServerUserV1)

Add user details to record. Does not overwrite existing users

func (*RecordV1) ToASBinSlice

func (r *RecordV1) ToASBinSlice() []*aerospike.Bin

ToASBinSlice - converts to aerospike bins. Currently writes record in recordv1 format

func (*RecordV1) ToRecordViewV1

func (r *RecordV1) ToRecordViewV1() RecordViewV1

type RecordViewV1

type RecordViewV1 struct {
	Metadata    MetadataViewV1   `json:"Metadata"`
	Account     AccountViewV1    `json:"Account"`
	Credentials CredentialsView1 `json:"Credentials"`
}

RecordViewV1 - Aerospike configuration + credentials data

Jump to

Keyboard shortcuts

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