secret

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package secret provides a simple interface to store and load secrets. It also provides some built-in implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InMemoryManagerWithGCTicker

func InMemoryManagerWithGCTicker(ticker time.Duration) func(*InMemoryManagerOptions)

InMemoryManagerWithGCTicker sets the amount of time that the garbage collector will run. By default, the garbage collector will run every minute.

func InMemoryManagerWithTTL

func InMemoryManagerWithTTL(ttl time.Duration) func(*InMemoryManagerOptions)

InMemoryManagerWithTTL sets the amount of time that the secret will be stored after it is idle (not accessed anymore). By default, the secret will be stored for 15 minutes.

Types

type InMemoryManager

type InMemoryManager struct {
	// contains filtered or unexported fields
}

InMemoryManager is a manager that stores the secrets in memory.

func NewInMemoryManager

func NewInMemoryManager(optFuncs ...func(*InMemoryManagerOptions)) *InMemoryManager

NewInMemoryManager creates a new InMemoryManager.

func (*InMemoryManager) Load

func (m *InMemoryManager) Load(id string) ([]byte, bool)

Load loads the secret from memory.

func (*InMemoryManager) Store

func (m *InMemoryManager) Store(id string, secret []byte) error

Store stores the secret in memory.

type InMemoryManagerOptions

type InMemoryManagerOptions struct {
	// contains filtered or unexported fields
}

InMemoryManagerOptions is used to configure the InMemoryManager.

type Manager

type Manager interface {
	Store(id string, secret []byte) error
	Load(id string) ([]byte, bool)
}

Manager is the interface that wraps the basic operations to store and load a secret.

Jump to

Keyboard shortcuts

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