server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Title string `json:"title"`
}

Config is the server configuration in which user can set the title of the UI

type CreateJobRequest

type CreateJobRequest struct {
	Name           string   `json:"name"`
	Type           string   `json:"type"` // duration, cron, daily, weekly, monthly
	Interval       int64    `json:"interval,omitempty"`
	CronExpression string   `json:"cronExpression,omitempty"`
	AtTime         string   `json:"atTime,omitempty"` // Format: HH:MM:SS
	Tags           []string `json:"tags,omitempty"`
}

CreateJobRequest represents the request to create a new job

type JobData

type JobData struct {
	ID             string   `json:"id"`
	Name           string   `json:"name"`
	Tags           []string `json:"tags"`
	NextRun        string   `json:"nextRun"`
	LastRun        string   `json:"lastRun"`
	NextRuns       []string `json:"nextRuns"`
	Schedule       string   `json:"schedule"`       // human-readable schedule description
	ScheduleDetail string   `json:"scheduleDetail"` // technical schedule details (cron expression, interval, etc.)
}

JobData represents the job information sent to clients

type Option

type Option func(*Server)

Option is a functional option for configuring the server

func WithTitle

func WithTitle(title string) Option

WithTitle sets a custom title for the UI

type Server

type Server struct {
	Scheduler gocron.Scheduler
	Router    http.Handler
	// contains filtered or unexported fields
}

Server is the main server struct which contains the scheduler, router, webSocket clients, webSocket mutex, upgrader, and config

func NewServer

func NewServer(scheduler gocron.Scheduler, _ int, opts ...Option) *Server

NewServer creates a new server instance

func (*Server) CreateJob

func (s *Server) CreateJob(w http.ResponseWriter, r *http.Request)

CreateJob creates a new job

func (*Server) DeleteJob

func (s *Server) DeleteJob(w http.ResponseWriter, r *http.Request)

DeleteJob deletes a job

func (*Server) GetConfig

func (s *Server) GetConfig(w http.ResponseWriter, _ *http.Request)

GetConfig gets server configuration

func (*Server) GetJob

func (s *Server) GetJob(w http.ResponseWriter, r *http.Request)

GetJob gets a single job

func (*Server) GetJobs

func (s *Server) GetJobs(w http.ResponseWriter, _ *http.Request)

GetJobs gets all jobs

func (*Server) HandleWebSocket

func (s *Server) HandleWebSocket(w http.ResponseWriter, r *http.Request)

HandleWebSocket is a webSocket handler

func (*Server) RunJob

func (s *Server) RunJob(w http.ResponseWriter, r *http.Request)

RunJob runs a job immediately

func (*Server) StartScheduler

func (s *Server) StartScheduler(w http.ResponseWriter, _ *http.Request)

StartScheduler starts the scheduler

func (*Server) StopScheduler

func (s *Server) StopScheduler(w http.ResponseWriter, _ *http.Request)

StopScheduler stops the scheduler

Jump to

Keyboard shortcuts

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