Documentation ¶
Overview ¶
Package firestoreFirestoreBackend implements Firestore storage backend for Teleport auth service, similar to DynamoDB backend.
firestore package implements the FirestoreBackend storage back-end for the auth server. Originally contributed by https://github.com/joshdurbin
Index ¶
- Constants
- func ConvertGRPCError(err error, args ...interface{}) error
- func CreateFirestoreClients(ctx context.Context, projectID string, endPoint string, credentialsFile string) (*apiv1.FirestoreAdminClient, *firestore.Client, error)
- func EnsureIndexes(ctx context.Context, adminSvc *apiv1.FirestoreAdminClient, ...) error
- func GetName() string
- func RetryingAsyncFunctionRunner(ctx context.Context, retryConfig utils.LinearConfig, logger *log.Logger, ...)
- type Config
- type FirestoreBackend
- func (cfg *FirestoreBackend) CheckAndSetDefaults() error
- func (b *FirestoreBackend) Clock() clockwork.Clock
- func (b *FirestoreBackend) Close() error
- func (b *FirestoreBackend) CloseWatchers()
- func (b *FirestoreBackend) CompareAndSwap(ctx context.Context, expected backend.Item, replaceWith backend.Item) (*backend.Lease, error)
- func (b *FirestoreBackend) Create(ctx context.Context, item backend.Item) (*backend.Lease, error)
- func (b *FirestoreBackend) Delete(ctx context.Context, key []byte) error
- func (b *FirestoreBackend) DeleteRange(ctx context.Context, startKey, endKey []byte) error
- func (b *FirestoreBackend) Get(ctx context.Context, key []byte) (*backend.Item, error)
- func (b *FirestoreBackend) GetRange(ctx context.Context, startKey []byte, endKey []byte, limit int) (*backend.GetResult, error)
- func (b *FirestoreBackend) KeepAlive(ctx context.Context, lease backend.Lease, expires time.Time) error
- func (b *FirestoreBackend) NewWatcher(ctx context.Context, watch backend.Watch) (backend.Watcher, error)
- func (b *FirestoreBackend) Put(ctx context.Context, item backend.Item) (*backend.Lease, error)
- func (b *FirestoreBackend) Update(ctx context.Context, item backend.Item) (*backend.Lease, error)
- type IndexTuple
Constants ¶
const (
// BackendName is the name of this backend
BackendName = "firestore"
)
Variables ¶
This section is empty.
Functions ¶
func ConvertGRPCError ¶
ConvertGRPCError converts GRPC errors
func CreateFirestoreClients ¶
func CreateFirestoreClients(ctx context.Context, projectID string, endPoint string, credentialsFile string) (*apiv1.FirestoreAdminClient, *firestore.Client, error)
CreateFirestoreClients creates a firestore admin and normal client given the supplied parameters
func EnsureIndexes ¶
func EnsureIndexes(ctx context.Context, adminSvc *apiv1.FirestoreAdminClient, tuples []*IndexTuple, indexParent string) error
EnsureIndexes is a function used by Firestore events and backend to generate indexes and will block until indexes are reported as created
func GetName ¶
func GetName() string
GetName is a part of backend API and it returns Firestore backend type as it appears in `storage/type` section of Teleport YAML
func RetryingAsyncFunctionRunner ¶
func RetryingAsyncFunctionRunner(ctx context.Context, retryConfig utils.LinearConfig, logger *log.Logger, task func() error, taskName string)
RetryingAsyncFunctionRunner wraps a task target in retry logic
Types ¶
type Config ¶
type Config struct { // Credentials path for the Firestore client CredentialsPath string `json:"credentials_path,omitempty"` // Google Project ID of Collection containing events ProjectID string `json:"project_id,omitempty"` // CollectName is the name of the collection containing events CollectionName string `json:"collection_name,omitempty"` // PurgeExpiredDocumentsPollInterval is the poll interval used to purge expired documents PurgeExpiredDocumentsPollInterval time.Duration `json:"purge_expired_documents_poll_interval,omitempty"` // RetryPeriod is a period between retry executions of long-lived document snapshot queries and purging expired records RetryPeriod time.Duration `json:"retry_period,omitempty"` // DisableExpiredDocumentPurge DisableExpiredDocumentPurge bool `json:"disable_expired_document_purge,omitempty"` // EndPoint is used to point the Firestore clients at emulated Firestore storage. EndPoint string `json:"endpoint,omitempty"` }
FirestoreConfig structure represents Firestore configuration as appears in `storage` section of Teleport YAML
type FirestoreBackend ¶
FirestoreBackend is a Firestore-backed key value backend implementation.
func New ¶
New returns new instance of Firestore backend. It's an implementation of backend API's NewFunc
func (*FirestoreBackend) CheckAndSetDefaults ¶
func (cfg *FirestoreBackend) CheckAndSetDefaults() error
CheckAndSetDefaults is a helper returns an error if the supplied configuration is not enough to connect to Firestore
func (*FirestoreBackend) Clock ¶
func (b *FirestoreBackend) Clock() clockwork.Clock
Clock returns wall clock
func (*FirestoreBackend) Close ¶
func (b *FirestoreBackend) Close() error
Close closes the Firestore client contexts and releases associated resources
func (*FirestoreBackend) CloseWatchers ¶
func (b *FirestoreBackend) CloseWatchers()
CloseWatchers closes all the watchers without closing the backend
func (*FirestoreBackend) CompareAndSwap ¶
func (b *FirestoreBackend) CompareAndSwap(ctx context.Context, expected backend.Item, replaceWith backend.Item) (*backend.Lease, error)
CompareAndSwap compares and swap values in atomic operation CompareAndSwap compares item with existing item and replaces is with replaceWith item
func (*FirestoreBackend) Delete ¶
func (b *FirestoreBackend) Delete(ctx context.Context, key []byte) error
Delete deletes item by key
func (*FirestoreBackend) DeleteRange ¶
func (b *FirestoreBackend) DeleteRange(ctx context.Context, startKey, endKey []byte) error
DeleteRange deletes range of items with keys between startKey and endKey
func (*FirestoreBackend) GetRange ¶
func (b *FirestoreBackend) GetRange(ctx context.Context, startKey []byte, endKey []byte, limit int) (*backend.GetResult, error)
GetRange returns range of elements
func (*FirestoreBackend) KeepAlive ¶
func (b *FirestoreBackend) KeepAlive(ctx context.Context, lease backend.Lease, expires time.Time) error
KeepAlive keeps object from expiring, updates lease on the existing object, expires contains the new expiry to set on the lease, some backends may ignore expires based on the implementation in case if the lease managed server side
func (*FirestoreBackend) NewWatcher ¶
func (b *FirestoreBackend) NewWatcher(ctx context.Context, watch backend.Watch) (backend.Watcher, error)
NewWatcher returns a new event watcher