mirror of
https://github.com/aykhans/bsky-feedgen.git
synced 2025-07-17 21:34:00 +00:00
🦋
This commit is contained in:
40
pkg/config/consumer.go
Normal file
40
pkg/config/consumer.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/aykhans/bsky-feedgen/pkg/types"
|
||||
"github.com/aykhans/bsky-feedgen/pkg/utils"
|
||||
)
|
||||
|
||||
type ConsumerConfig struct {
|
||||
PostMaxDate time.Duration
|
||||
PostCollectionCutoffCronDelay time.Duration
|
||||
PostCollectionCutoffCronMaxDocument int64
|
||||
}
|
||||
|
||||
func NewConsumerConfig() (*ConsumerConfig, types.ErrMap) {
|
||||
errs := make(types.ErrMap)
|
||||
maxDate, err := utils.GetEnv[time.Duration]("POST_MAX_DATE")
|
||||
if err != nil {
|
||||
errs["POST_MAX_DATE"] = err
|
||||
}
|
||||
cronDelay, err := utils.GetEnv[time.Duration]("POST_COLLECTION_CUTOFF_CRON_DELAY")
|
||||
if err != nil {
|
||||
errs["POST_COLLECTION_CUTOFF_CRON_DELAY"] = err
|
||||
}
|
||||
cronMaxDocument, err := utils.GetEnv[int64]("POST_COLLECTION_CUTOFF_CRON_MAX_DOCUMENT")
|
||||
if err != nil {
|
||||
errs["POST_COLLECTION_CUTOFF_CRON_MAX_DOCUMENT"] = err
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
return nil, errs
|
||||
}
|
||||
|
||||
return &ConsumerConfig{
|
||||
PostMaxDate: maxDate,
|
||||
PostCollectionCutoffCronDelay: cronDelay,
|
||||
PostCollectionCutoffCronMaxDocument: cronMaxDocument,
|
||||
}, nil
|
||||
}
|
Reference in New Issue
Block a user