github.com/ashishbhate/mattermost-server@v5.11.1+incompatible/jobs/server.go (about)

     1  // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package jobs
     5  
     6  import (
     7  	ejobs "github.com/mattermost/mattermost-server/einterfaces/jobs"
     8  	tjobs "github.com/mattermost/mattermost-server/jobs/interfaces"
     9  	"github.com/mattermost/mattermost-server/model"
    10  	"github.com/mattermost/mattermost-server/services/configservice"
    11  	"github.com/mattermost/mattermost-server/store"
    12  )
    13  
    14  type JobServer struct {
    15  	ConfigService configservice.ConfigService
    16  	Store         store.Store
    17  	Workers       *Workers
    18  	Schedulers    *Schedulers
    19  
    20  	DataRetentionJob        ejobs.DataRetentionJobInterface
    21  	MessageExportJob        ejobs.MessageExportJobInterface
    22  	ElasticsearchAggregator ejobs.ElasticsearchAggregatorInterface
    23  	ElasticsearchIndexer    ejobs.ElasticsearchIndexerInterface
    24  	LdapSync                ejobs.LdapSyncInterface
    25  	Migrations              tjobs.MigrationsJobInterface
    26  	Plugins                 tjobs.PluginsJobInterface
    27  }
    28  
    29  func NewJobServer(configService configservice.ConfigService, store store.Store) *JobServer {
    30  	return &JobServer{
    31  		ConfigService: configService,
    32  		Store:         store,
    33  	}
    34  }
    35  
    36  func (srv *JobServer) Config() *model.Config {
    37  	return srv.ConfigService.Config()
    38  }
    39  
    40  func (srv *JobServer) StartWorkers() {
    41  	srv.Workers = srv.Workers.Start()
    42  }
    43  
    44  func (srv *JobServer) StartSchedulers() {
    45  	srv.Schedulers = srv.Schedulers.Start()
    46  }
    47  
    48  func (srv *JobServer) StopWorkers() {
    49  	if srv.Workers != nil {
    50  		srv.Workers.Stop()
    51  	}
    52  }
    53  
    54  func (srv *JobServer) StopSchedulers() {
    55  	if srv.Schedulers != nil {
    56  		srv.Schedulers.Stop()
    57  	}
    58  }