Customization | laravel-schedule-monitor-go | Spatie       

 SPATIE  

laravel-schedule-monitor-go
===========================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-schedule-monitor-go](https://spatie.be/docs/laravel-schedule-monitor-go/v1)  Customization

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/laravel-schedule-monitor-go/v1) 

  Customization    
- [ Introduction ](https://spatie.be/docs/laravel-schedule-monitor-go/v1/introduction)
- [ Installation and setup ](https://spatie.be/docs/laravel-schedule-monitor-go/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/laravel-schedule-monitor-go/v1/usage)
- [ Monitoring and Oh Dear ](https://spatie.be/docs/laravel-schedule-monitor-go/v1/monitoring)
- [ Customization ](https://spatie.be/docs/laravel-schedule-monitor-go/v1/customization)
- [ Testing ](https://spatie.be/docs/laravel-schedule-monitor-go/v1/testing)
- [ Releasing ](https://spatie.be/docs/laravel-schedule-monitor-go/v1/releasing)
- [ Changelog ](https://spatie.be/docs/laravel-schedule-monitor-go/v1/changelog)
- [ Support us ](https://spatie.be/docs/laravel-schedule-monitor-go/v1/support-us)

 Customization
=============

###  On this page 

1. [ Models ](#content-models)
2. [ Jobs ](#content-jobs)
3. [ Profiles and task policy ](#content-profiles-and-task-policy)

Models
--------------------------------------------------------------------------

PHP lets you replace the monitored task and log models. In Go, `Config.Store` owns those operations. Every command, scheduler listener, status query and queued job uses that store, including ping lookup and acknowledgement.

Implement `Store` with your own models, table names, connections and hooks. `DatabaseStore` is exported so you can retain operations that do not need changing. Set `cfg.Migrations = false` when using your own schema and register migrations through the native registrar.

```
schedulemonitor.New(func(cfg *schedulemonitor.Config) {
    cfg.Store = applicationStore
    cfg.Migrations = false
})
```

`applicationStore` is your implementation of `schedulemonitor.Store`. It must preserve these contracts:

- `Sync` retains task IDs, creation times and health history for existing names. Delete old logs with their tasks when `keepOld` is false. Clear ping URLs and pending markers for local-only names.
- `Record` saves log metadata and task timestamps atomically, and returns nil for unknown names. Return a persisted log with `Pending` set only when it should be queued and a ping URL exists.
- Start and skip events must not clear the last terminal failure. A success sets `LastTerminal` to `finished`. A failure sets it to `failed`, including timestamp ties.
- `FindLog`, `Logs`, `Tasks`, `BindPing` and `MarkPinged` must read and update the same models used by `Record` and `Sync`.
- A zero task ID passed to `MarkPinged` clears only the log's pending marker. This expires a log without claiming the task was pinged.
- `Prune` deletes non-pending logs at or before its cutoff and leaves task health untouched.

The test `TestCustomModelsAndJobWorkThroughPersistenceAndWorker` uses application-owned task and log model types to write extra columns. It verifies the replacement via sync, event persistence, a serialized database-queue job and acknowledgement. Use it as an executable example.

Jobs
--------------------------------------------------------------------

```
type CustomPingJob struct {
    LogID int64 `json:"log_id"`
}

func (j CustomPingJob) Handle(ctx context.Context) error {
    return schedulemonitor.From(ctx).Ping(ctx, j.LogID)
}

schedulemonitor.New(func(cfg *schedulemonitor.Config) {
    cfg.PingJob = func(id int64) any {
        return CustomPingJob{LogID: id}
    }
})
```

The factory is called with `0` to register its concrete type, then with the persisted log ID when dispatching. Always return the same job type. Keep fields serializable and carry IDs rather than stores or closures. The selected type is registered automatically, so a real worker can decode it.

Add a native `JobOptions() queue.Options` method to customize retries, timeout or queue. `OH_DEAR_QUEUE`, when non-empty, overrides the job's default queue. The default job retries for ten minutes with ten-second queue backoff. `cfg.OhDear.Lifetime` independently expires logs based on event age, so retries never renew an old event.

Profiles and task policy
--------------------------------------------------------------------------------------------------------------------------------

The PHP package has no separate configurable profile class. `Config.Tasks` exposes its per-task policy settings. Callbacks run after environment defaults. Configure stores and factories here rather than registering another `*Monitor` service, because Laravel Go v0.1.0 resolves the first registered service of a type.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
