Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambda handler improvements #14

Merged
merged 2 commits into from
Aug 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cmd/almendruco/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,32 @@ import (
const appName = "almendruco"

func main() {
lambda.Start(lambdaHandler())
lambda.Start(lambdaHandler)
}

func lambdaHandler() error {
cfg := config{}
if err := envconfig.Process(appName, &cfg); err != nil {
log.Fatalf("Configuration processing failed: %s", err)
return fmt.Errorf("configuration processing failed: %w", err)
}

r, err := dynamodbrepo.NewRepo()
if err != nil {
log.Fatalf("Unable to initialize repository: %s", err)
return fmt.Errorf("unable to initialize repository: %w", err)
}

rc, err := raices.NewClient(cfg.Raices.BaseURL)
if err != nil {
log.Fatalf("Error creating Raíces client: %s", err)
return fmt.Errorf("error creating Raíces client: %w", err)
}

n, err := notifier.NewTelegramNotifier(cfg.Telegram.BaseURL, cfg.Telegram.BotToken)
if err != nil {
log.Fatalf("Error creating notifier: %s", err)
return fmt.Errorf("error creating notifier: %w", err)
}

if err := notifyMessages(r, rc, n); err != nil {
return fmt.Errorf("error notifying messages: %s", err)
return fmt.Errorf("error notifying messages: %w", err)
}

log.Println("Success!")
Expand Down
Loading