Documentation ¶
Index ¶
- Variables
- type Redis
- func (storage Redis) Create(schedule *schedule.Schedule) (*int, error)
- func (storage Redis) Get(scheduleID int) (*schedule.Schedule, error)
- func (storage Redis) Search(pollInterval time.Duration) ([]*schedule.Schedule, error)
- func (storage Redis) Update(schedule *schedule.Schedule, updateTimestamp bool) error
- type Storage
- type StorageFactory
Constants ¶
This section is empty.
Variables ¶
var NewRedisStorage = func(config map[string]interface{}) (Storage, error) { dsn, ok := config["dsn"] if !ok { err := fmt.Errorf("the DSN configuration option is required for the Redis storage") return nil, err } sDSN := dsn.(string) client, err := redis.Dial("tcp", sDSN) if err != nil { err := fmt.Errorf("failed to connect to Redis: %s", err.Error()) return nil, err } storage := Redis{ dsn: sDSN, client: client, } return storage, nil }
NewRedisStorage implements the StorageFactory function type. It initiates a connection to the Redis database defined in the given configuration, and it returns the Storage engine object.
Functions ¶
This section is empty.
Types ¶
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
Redis implements the Storage interface, allowing to use Redis as a Storage engine.
func (Redis) Create ¶
Create implements Storage.Create(). It stores the given Schedule object as a new Hash in the Redis Storage and it returns an automatically generated ID.
func (Redis) Get ¶
Get implements Storage.Get(). It retrieves from Storage and returns the Schedule for the given ID.
type Storage ¶
type Storage interface { Create(*schedule.Schedule) (*int, error) Get(int) (*schedule.Schedule, error) Update(*schedule.Schedule, bool) error Search(time.Duration) ([]*schedule.Schedule, error) }
Storage is an interface that should be implemented by all Storage engines. It defines an API for storing and retrieving Schedule objects.
type StorageFactory ¶
StorageFactory is a function type that should be implemented by all Storage engine factories. It defines a function type that receives the required configuration as a map, and it returns the Storage engine object. The configuration should include the requested engine keyed "STORAGE_ENGINE" plus any configuration required by the engine itself.