syntax = "proto3";

package scheduler;

option go_package = "github.com/navidrome/navidrome/plugins/host/scheduler;scheduler";

// go:plugin type=host version=1
service SchedulerService {
    // One-time event scheduling
    rpc ScheduleOneTime(ScheduleOneTimeRequest) returns (ScheduleResponse);
    
    // Recurring event scheduling
    rpc ScheduleRecurring(ScheduleRecurringRequest) returns (ScheduleResponse);
    
    // Cancel any scheduled job
    rpc CancelSchedule(CancelRequest) returns (CancelResponse);
}

message ScheduleOneTimeRequest {
    int32 delay_seconds = 1;       // Delay in seconds
    bytes payload = 2;             // Serialized data to pass to the callback
    string schedule_id = 3;        // Optional custom ID (if not provided, one will be generated)
}

message ScheduleRecurringRequest {
    string cron_expression = 1;    // Cron expression (e.g. "0 0 * * *" for daily at midnight)
    bytes payload = 2;             // Serialized data to pass to the callback
    string schedule_id = 3;        // Optional custom ID (if not provided, one will be generated)
}

message ScheduleResponse {
    string schedule_id = 1;        // ID to reference this scheduled job
}

message CancelRequest {
    string schedule_id = 1;        // ID of the schedule to cancel
}

message CancelResponse {
    bool success = 1;              // Whether cancellation was successful
    string error = 2;              // Error message if cancellation failed
} 