server

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 14 Imported by: 2

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"`
	APIEnabled       bool   `json:"api_enabled"`
	WebSocketEnabled bool   `json:"websocket_enabled"`
}

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.)
	SchedulerName  string   `json:"schedulerName"`
}

JobData represents the job information sent to clients

type Option

type Option func(*Server)

Option is a functional option for configuring the server

func WithAPIDisabled added in v0.2.0

func WithAPIDisabled() Option

WithAPIDisabled disables API

func WithAdditionalScheduler added in v0.4.0

func WithAdditionalScheduler(name string, scheduler gocron.Scheduler) Option

WithAdditionalScheduler adds an additional scheduler to the server

func WithBasePath added in v0.4.0

func WithBasePath(path string) Option

WithBasePath sets a base path for the server

func WithTitle

func WithTitle(title string) Option

WithTitle sets a custom title for the UI

func WithWebSocketDisabled added in v0.2.0

func WithWebSocketDisabled() Option

WithWebSocketDisabled disables webSocket

type Server

type Server struct {
	Schedulers     []gocron.Scheduler
	SchedulerNames []string
	Router         http.Handler
	// contains filtered or unexported fields
}

Server is the main server struct which contains the schedulers, 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 all schedulers

func (*Server) StopScheduler

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

StopScheduler stops all schedulers

Jump to

Keyboard shortcuts

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