Skip to content

Service that is responsible for once a day sending a gRPC call to a microservice so that it triggers the creation and delivery of the daily email digests for our customers.

Notifications You must be signed in to change notification settings

kvist-no/digestive

Repository files navigation

Digestive

CI

An app for sending a preconfigured gRPC command to trigger daily email digest generation. Purpose built to be run as a CronJob in a Kubernetes cluster with Sentry monitoring.

How It Works

The service performs these steps:

  1. Reports job start to Sentry for monitoring
  2. Connects to your notification service via gRPC and sends a command to trigger digest email generation
  3. Reports success/failure status back to Sentry

Configuration

Configure the service using these environment variables:

Required Variables

# Which environment we're running in (used for Sentry monitoring)
ENVIRONMENT=staging
CRON_URL=https://oxxxxxxxxxxxxxxxx.ingest.de.sentry.io/api/xxxxxxxxxxxxxxxx/cron/digest-trigger/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
NOTIFICATION_SERVICE_URL=https://notification.init.svc.cluster.local:8080
RUST_LOG=info

Optional Variables (with defaults)

# Who is sending the command (shown in logs and potentially forwarded)
COMMAND_FROM="Kubernetes Debrief Trigger CronJob"
# The specific command to send to the notification service
COMMAND_COMMAND="SendDigestEmailsCommand"
# JSON data payload for the command
COMMAND_DATA="{\"template\":\"daily-digest\"}"
# Optional requester identifier
COMMAND_REQUESTER=""

Local Development & Testing

Prerequisites

  • Rust 1.70+ (rustup recommended)
  • Protocol Buffers compiler (protoc)

On macOS:

brew install protobuf

Build and Run

Use task. Update .env.local to point to your local notification service.

Monitoring Your CronJob

  • Check CronJob status: kubectl get cronjobs
  • View recent job runs: kubectl get jobs
  • Check logs: kubectl logs -l job-name=digestive-daily-<timestamp>
  • Monitor in Sentry for cron job health and failure alerts

Deployment as Kubernetes CronJob

This service is designed to run as a Kubernetes CronJob.

Production Usage: This service is currently deployed in production at kvist-no/infra.

Here's an example configuration:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: digestive-daily
  namespace: your-namespace
spec:
  # Run every day at 8 AM UTC
  schedule: "0 8 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
          - name: digestive
            image: your-registry/digestive:latest
            env:
            - name: ENVIRONMENT
              value: "staging"
            - name: CRON_URL
              valueFrom:
                secretKeyRef:
                  name: digestive-secrets
                  key: sentry-cron-url
            - name: NOTIFICATION_SERVICE_URL
              value: "https://notification.init.svc.cluster.local:8080"
            - name: RUST_LOG
              value: "info"
            - name: COMMAND_DATA
              value: '{"template":"daily-digest"}'
            resources:
              requests:
                memory: "32Mi"
                cpu: "10m"
              limits:
                memory: "64Mi"
                cpu: "100m"
          # Clean up completed jobs after 3 successful runs and 1 failed run
          successfulJobsHistoryLimit: 3
          failedJobsHistoryLimit: 1

Kubernetes Secret for Sentry URL

apiVersion: v1
kind: Secret
metadata:
  name: digestive-secrets
  namespace: your-namespace
type: Opaque
stringData:
  sentry-cron-url: "https://oxxxxxxxxxxxxxxxx.ingest.de.sentry.io/api/xxxxxxxxxxxxxxxx/cron/digest-trigger/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/"

About

Service that is responsible for once a day sending a gRPC call to a microservice so that it triggers the creation and delivery of the daily email digests for our customers.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •