feat: planned structure
This commit is contained in:
parent
bcb9ace54c
commit
5240968c33
4 changed files with 41 additions and 4 deletions
22
internal/pkg/grib/config.go
Normal file
22
internal/pkg/grib/config.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package downloader
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
env "github.com/caarlos0/env/v11"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
}
|
||||
|
||||
func NewConfig(servicePrefix string) (*Config, error) {
|
||||
cfg := &Config{}
|
||||
|
||||
if err := env.ParseWithOptions(cfg, env.Options{
|
||||
PrefixTagName: fmt.Sprintf("%s_GRIB_", servicePrefix),
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
3
internal/pkg/grib/grib.go
Normal file
3
internal/pkg/grib/grib.go
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
package downloader
|
||||
|
||||
//
|
||||
|
|
@ -11,6 +11,6 @@ type Redis interface {
|
|||
Get(key string) ([]byte, error)
|
||||
}
|
||||
|
||||
type Downloader interface {
|
||||
Download(ctx context.Context)
|
||||
type Grib interface {
|
||||
Update(ctx context.Context) error
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,22 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
redis Redis
|
||||
downloader Downloader
|
||||
}
|
||||
|
||||
func New() *Service {
|
||||
return &Service{}
|
||||
func New(redis Redis, downloader Downloader) *Service {
|
||||
return &Service{
|
||||
redis: redis,
|
||||
downloader: downloader,
|
||||
}
|
||||
}
|
||||
|
||||
// DownloadWeatherData downloads weather forecast data using the configured downloader
|
||||
func (s *Service) DownloadWeatherData(ctx context.Context) error {
|
||||
return s.downloader.Download(ctx)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue