barngo

package module
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2024 License: MIT Imports: 1 Imported by: 0

README

Barn

This is a simple scheduler with a database store (it was tested only with PostgreSQL)

Usage of scheduler

package main

import (
	"context"
	"database/sql"
	"os"
	"os/signal"

	"github.com/bibenga/barn-go/scheduler"
)

func main() {
	db, err := sql.Open("pgx", "host=rds port=5432 user=rds password=sqlsql dbname=rds TimeZone=UTC sslmode=disable")
	if err != nil {
		panic(err)
	}
	defer db.Close()

	repository := scheduler.NewDefaultPostgresSchedulerRepository()

	ctx, cancel := context.WithCancel(context.Background())

	sched := scheduler.NewScheduler(db, &scheduler.SchedulerConfig{Repository: repository})
	sched.StartContext(ctx)

	osSignal := make(chan os.Signal, 1)
	signal.Notify(osSignal, os.Interrupt)
	s := <-osSignal
	
    cancel()
    sched.Stop()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunInTransaction

func RunInTransaction(db *sql.DB, f func(tx *sql.Tx) error) error

Types

This section is empty.

Directories

Path Synopsis
complex command
leader command
lock command
queue command
scheduler command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL