Documentation ¶
Index ¶
- Constants
- Variables
- func AddRecord(r micro.Request, app AppContext) error
- func AppGroup(svc micro.Service, logger *logr.Logger, appCtx AppContext)
- func AppHandler(logger *logr.Logger, h AppHandlerFunc, app AppContext) micro.HandlerFunc
- func DBGroup(svc micro.Service, logger *logr.Logger, appCtx AppContext)
- func DeleteRecord(r micro.Request, app AppContext) error
- func GetClientDBVerbs() []string
- func GetRecord(r micro.Request, app AppContext) error
- func HashPassword(s string) string
- func Initialize(r micro.Request, app AppContext) error
- func Lock(r micro.Request, app AppContext) error
- func RotateKey(r micro.Request, app AppContext) error
- func SanitizeKey(k string) string
- func Status(r micro.Request, app AppContext) error
- func Unlock(r micro.Request, app AppContext) error
- func WatchForConfig(logger *logr.Logger, js nats.JetStreamContext)
- type AppContext
- type AppHandlerFunc
- type Backend
- type Client
- type ClientError
- type DBVerb
- type DatabaseKey
- type DbRequest
- type JetStreamRecord
- type KV
- type Password
- type Request
- type ResponseError
- type ResponseMessage
- type RotateRequest
- type Verb
- type Watcher
Constants ¶
const ( DBInit DBVerb = "init" DBLock DBVerb = "lock" DBUnlock DBVerb = "unlock" DBStatus DBVerb = "status" DBRotate DBVerb = "rotate" GET Verb = "GET" POST Verb = "POST" DELETE Verb = "DELETE" )
const (
Bucket = "piggybank"
)
Variables ¶
var SubjectVerbs = map[DBVerb]string{ DBInit: fmt.Sprintf("%s.%s", databaseSubject, databaseInitSubject), DBLock: fmt.Sprintf("%s.%s", databaseSubject, databaseLockSubject), DBUnlock: fmt.Sprintf("%s.%s", databaseSubject, databaseUnlockSubject), DBStatus: fmt.Sprintf("%s.%s", databaseSubject, databaseStatusSubject), DBRotate: fmt.Sprintf("%s.%s", databaseSubject, databaseRotateSubject), }
Functions ¶
func AppGroup ¶ added in v0.1.1
func AppGroup(svc micro.Service, logger *logr.Logger, appCtx AppContext)
func AppHandler ¶
func AppHandler(logger *logr.Logger, h AppHandlerFunc, app AppContext) micro.HandlerFunc
ErrorHandler wraps a normal micro endpoint and allows for returning errors natively. Errors are checked and if an error is a client error, details are returned, otherwise a 500 is returned and logged
func DBGroup ¶ added in v0.1.1
func DBGroup(svc micro.Service, logger *logr.Logger, appCtx AppContext)
func DeleteRecord ¶
func DeleteRecord(r micro.Request, app AppContext) error
func GetClientDBVerbs ¶ added in v0.1.1
func GetClientDBVerbs() []string
func HashPassword ¶
func Initialize ¶
func Initialize(r micro.Request, app AppContext) error
func SanitizeKey ¶ added in v0.3.0
func Status ¶
func Status(r micro.Request, app AppContext) error
Wrap Status in secret handler so it will catch locked requests
func WatchForConfig ¶
Types ¶
type AppContext ¶
type AppContext struct { KV nats.KeyValue // contains filtered or unexported fields }
func (*AppContext) AddRecord ¶
func (a *AppContext) AddRecord(k KV) error
func (*AppContext) DeleteRecord ¶
func (a *AppContext) DeleteRecord(k KV) error
func (*AppContext) Rotate ¶ added in v0.3.0
func (a *AppContext) Rotate(currentKey string) ([]byte, error)
func (*AppContext) Unlock ¶
func (a *AppContext) Unlock(k KV) error
type AppHandlerFunc ¶
type AppHandlerFunc func(micro.Request, AppContext) error
func SecretHandler ¶
func SecretHandler(a AppHandlerFunc) AppHandlerFunc
SecretHandler wraps any secret handlers to check if database is currently locked
type ClientError ¶
func NewClientError ¶
func NewClientError(err error, code int) ClientError
func (ClientError) As ¶
func (c ClientError) As(target any) bool
func (*ClientError) Body ¶
func (c *ClientError) Body() []byte
func (*ClientError) CodeString ¶
func (c *ClientError) CodeString() string
func (ClientError) Error ¶
func (c ClientError) Error() string
type DatabaseKey ¶
type DatabaseKey struct {
DBKey string `json:"database_key"`
}
type JetStreamRecord ¶
type JetStreamRecord struct {
// contains filtered or unexported fields
}
func (*JetStreamRecord) Bucket ¶
func (j *JetStreamRecord) Bucket() string
Bucket returns the Bucket value for the JetStreamRecord
func (*JetStreamRecord) Decrypt ¶
func (j *JetStreamRecord) Decrypt() ([]byte, error)
Decrypt decrypts the value of the JetStreamRecord using the encryption key stored in the record
func (*JetStreamRecord) Encrypt ¶
func (j *JetStreamRecord) Encrypt() error
Encrypt encrypts the value of the JetStreamRecord using the encryption key stored in the record
func (*JetStreamRecord) Key ¶
func (j *JetStreamRecord) Key() string
Key returns the Key for the JetStreamRecord
func (*JetStreamRecord) Value ¶
func (j *JetStreamRecord) Value() []byte
Value returns the JetStreamRecord value
type Password ¶
type Password struct { PlainText string `json:"password"` // contains filtered or unexported fields }
type ResponseError ¶ added in v0.2.1
type ResponseError struct {
Error string `json:"error"`
}
type ResponseMessage ¶
type ResponseMessage struct {
Details string `json:"details,omitempty"`
}
ResponseMessage holds a response to the caller
type RotateRequest ¶ added in v0.3.0
type RotateRequest struct {
CurrentKey string `json:"current_key"`
}