github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/model/job/trigger_client.go (about)

     1  package job
     2  
     3  // ClientTrigger implements the @webhook triggers. It schedules a job when an
     4  // HTTP request is made at this webhook.
     5  type ClientTrigger struct {
     6  	*TriggerInfos
     7  }
     8  
     9  // NewClientTrigger returns a new instance of ClientTrigger.
    10  func NewClientTrigger(infos *TriggerInfos) (*ClientTrigger, error) {
    11  	infos.WorkerType = "client" // Force the worker type
    12  	return &ClientTrigger{infos}, nil
    13  }
    14  
    15  // Type implements the Type method of the Trigger interface.
    16  func (c *ClientTrigger) Type() string {
    17  	return c.TriggerInfos.Type
    18  }
    19  
    20  // Schedule implements the Schedule method of the Trigger interface.
    21  func (c *ClientTrigger) Schedule() <-chan *JobRequest {
    22  	return nil
    23  }
    24  
    25  // Unschedule implements the Unschedule method of the Trigger interface.
    26  func (c *ClientTrigger) Unschedule() {}
    27  
    28  // Infos implements the Infos method of the Trigger interface.
    29  func (c *ClientTrigger) Infos() *TriggerInfos {
    30  	return c.TriggerInfos
    31  }
    32  
    33  // CombineRequest implements the CombineRequest method of the Trigger interface.
    34  func (c *ClientTrigger) CombineRequest() string {
    35  	return keepOriginalRequest
    36  }