Documentation
¶
Overview ¶
Package deckv provides a simple and efficient blocklist implementation with support for multiple storage backends.
Deckv allows you to manage and check against blocklists (e.g., email domains, IP addresses, usernames) using either in-memory storage or Redis as a backend.
Basic usage with in-memory storage:
client := deckv.New(deckv.WithConfFilePath("./blocklist.conf"))
err := client.Load(context.Background())
if err != nil {
log.Fatal(err)
}
blocked, err := client.Check(context.Background(), "blocked-domain.com")
Using with Redis storage:
storage := deckvredis.New(context.Background(), deckvredis.Config{
Host: "localhost",
Port: "6379",
})
client := deckv.New(
deckv.WithConfFilePath("./blocklist.conf"),
deckv.WithStorage(storage),
)
Package deckv provides blocklist functionality with multiple storage backend support.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Deckv represents the main blocklist client.
type Config ¶
type Config struct {
ConfigFileBytes []byte
Storage DataStorage
}
Config holds the configuration for Deckv instance.
type DataStorage ¶
type DataStorage interface {
// Save stores the provided blocklist data in the storage backend.
Save(ctx context.Context, data map[string]uint8) error
// Check verifies if a key exists in the storage backend.
Check(ctx context.Context, key string) (bool, error)
}
DataStorage defines the interface for blocklist storage backends.
type InMemStorage ¶
type InMemStorage struct {
// contains filtered or unexported fields
}
InMemStorage implements DataStorage interface using in-memory storage.
type Option ¶
type Option func(*Config)
Option defines a function type for configuring Deckv instances.
func WithConfFileBytes ¶
WithConfFileBytes sets the blocklist configuration file content as bytes. This is the preferred method for providing configuration to avoid file path security issues.
func WithStorage ¶
func WithStorage(storage DataStorage) Option
WithStorage sets the storage backend to use for the blocklist.