repositories

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWebhookNotFound = errors.New("webhook not found")

ErrWebhookNotFound is an error that indicates that the requested webhook was not found.

Functions

This section is empty.

Types

type WebhookStubRepository

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

WebhookStubRepository is a simple in-memory implementation of the WebhookRepository interface.

It stores the UUIDs and their associated values in a map. The mutex is used to synchronize access to the map.

Fields:

storage is a map that stores the UUIDs and their associated values. The map is used to store the UUIDs as keys and their associated values as values.

mu is a mutex used to synchronize access to the storage map. The mutex is used to ensure that only one goroutine can modify the storage map at a time.

func NewWebhookRepository

func NewWebhookRepository(storage map[uuid.UUID]string) *WebhookStubRepository

NewWebhookRepository creates a new instance of the WebhookStubRepository.

This function takes a map that stores the UUIDs and their associated values as input and returns a pointer to the newly created WebhookStubRepository. The WebhookStubRepository is a simple in-memory implementation of the WebhookRepository interface, which stores the UUIDs and their associated values in a map.

Parameters: - storage: A map that stores the UUIDs and their associated values.

Returns: - A pointer to the newly created WebhookStubRepository.

func (*WebhookStubRepository) All

func (w *WebhookStubRepository) All() []uuid.UUID

All returns all keys from the storage.

This function returns all keys from the storage as a slice of UUIDs. It locks the mutex to prevent concurrent access to the storage.

Parameters: - None

Returns: - A slice of UUIDs.

func (*WebhookStubRepository) Get

Get retrieves the value associated with the given UUID from the storage.

Parameters: - ctx: The context.Context used to cancel the operation if needed. - id: The UUID of the webhook.

Returns: - The value associated with the given UUID. - An error if the UUID is not found.

The function locks the mutex to prevent concurrent access to the storage. It retrieves the value associated with the given UUID from the storage. If the UUID is not found, it returns an error. Otherwise, it returns the value associated with the given UUID.

Jump to

Keyboard shortcuts

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