Working on refactoring jobs service (#19205)
* Working on refactoring jobs service * Making more consistent with the previous existing code * Remove no longer needed functions * Making a base PeridicScheduler to use it in most of the schedulers implementations * Removing accidental complexity from on of the jobs * Removing accidental complexity from expirynotify * Fixing compilation from previous commit * Remove accidental complexity from the export_delete job * Simplifying the workers by making a reusable worker * Using simple worker for export_delete job * Simpliying export process job * Simpliying extract content job * Simpliying import delete job * Simpliying import process job * Simpliying product noticies job * Simpliying fix crt channel unreads job (only removing the uneeded register function) * Simpliying migrations job (only removing the uneeded register function) * fixup * Simpliying plugins job (only removing the uneeded register function) * Simpliying bleve indexing job (only removing the uneeded register function) * Simpliying resend invitation email job (only removing the uneeded register function) * Fixing tests * Simplifying migration tests infrastructure * Adding missed license to files * Adding an empty file to imports package to ensure this package exist even without enterprise repo * Regenerating einterfaces mocks * Adding missed license to files * Updating i18n/en.json file * help fixing enterprise tests compilation * Adding new DailyScheduler * Fixing typo and changing the waitTime type for periodic sechduler * Making the daily scheduler more generic * Adding comments to clarify not used parameters in interface scheduler interface implementations * Using merror to handle multiple errors in jobs workers * Fixing linter errors * Addressing PR review comments * Reverting go.tools.mod changes * Removing the static check for worker type in the model (moving it to the insertion of new jobs * Moving migrations job to the jobs directory * Fixing (and improving a bit) tests * Apply suggestions from code review Co-authored-by: Doug Lauder <wiggin77@warpmail.net> * Fixing enterprise tests * Removing unneeded InitWorkers/InitSchedulers calls * Fix expirenotify job when error happens * Fixing govet errors Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Doug Lauder <wiggin77@warpmail.net>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7398451030
Коммит
2c3e289509
@@ -236,7 +236,7 @@ type AppIface interface {
|
||||
// NewWebConn returns a new WebConn instance.
|
||||
NewWebConn(cfg *WebConnConfig) *WebConn
|
||||
// NotifySessionsExpired is called periodically from the job server to notify any mobile sessions that have expired.
|
||||
NotifySessionsExpired() *model.AppError
|
||||
NotifySessionsExpired() error
|
||||
// OverrideIconURLIfEmoji changes the post icon override URL prop, if it has an emoji icon,
|
||||
// so that it points to the URL (relative) of the emoji - static if emoji is default, /api if custom.
|
||||
OverrideIconURLIfEmoji(post *model.Post)
|
||||
@@ -405,7 +405,7 @@ type AppIface interface {
|
||||
BuildPostReactions(postID string) (*[]ReactionImportData, *model.AppError)
|
||||
BuildPushNotificationMessage(contentsConfig string, post *model.Post, user *model.User, channel *model.Channel, channelName string, senderName string, explicitMention bool, channelWideMention bool, replyToThreadType string) (*model.PushNotification, *model.AppError)
|
||||
BuildSamlMetadataObject(idpMetadata []byte) (*model.SamlMetadataResponse, *model.AppError)
|
||||
BulkExport(writer io.Writer, outPath string, opts BulkExportOpts) *model.AppError
|
||||
BulkExport(writer io.Writer, outPath string, opts model.BulkExportOpts) *model.AppError
|
||||
BulkImport(c *request.Context, jsonlReader io.Reader, attachmentsReader *zip.Reader, dryRun bool, workers int) (*model.AppError, int)
|
||||
BulkImportWithPath(c *request.Context, jsonlReader io.Reader, attachmentsReader *zip.Reader, dryRun bool, workers int, importPath string) (*model.AppError, int)
|
||||
CancelJob(jobId string) *model.AppError
|
||||
|
||||
@@ -6,7 +6,6 @@ package app
|
||||
import (
|
||||
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
||||
ejobs "github.com/mattermost/mattermost-server/v6/einterfaces/jobs"
|
||||
tjobs "github.com/mattermost/mattermost-server/v6/jobs/interfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/services/searchengine"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
@@ -60,9 +59,9 @@ func RegisterJobsElasticsearchAggregatorInterface(f func(*Server) ejobs.Elastics
|
||||
jobsElasticsearchAggregatorInterface = f
|
||||
}
|
||||
|
||||
var jobsElasticsearchIndexerInterface func(*Server) tjobs.IndexerJobInterface
|
||||
var jobsElasticsearchIndexerInterface func(*Server) ejobs.IndexerJobInterface
|
||||
|
||||
func RegisterJobsElasticsearchIndexerInterface(f func(*Server) tjobs.IndexerJobInterface) {
|
||||
func RegisterJobsElasticsearchIndexerInterface(f func(*Server) ejobs.IndexerJobInterface) {
|
||||
jobsElasticsearchIndexerInterface = f
|
||||
}
|
||||
|
||||
@@ -72,85 +71,12 @@ func RegisterJobsLdapSyncInterface(f func(*Server) ejobs.LdapSyncInterface) {
|
||||
jobsLdapSyncInterface = f
|
||||
}
|
||||
|
||||
var jobsMigrationsInterface func(*Server) tjobs.MigrationsJobInterface
|
||||
|
||||
func RegisterJobsMigrationsJobInterface(f func(*Server) tjobs.MigrationsJobInterface) {
|
||||
jobsMigrationsInterface = f
|
||||
}
|
||||
|
||||
var jobsPluginsInterface func(*Server) tjobs.PluginsJobInterface
|
||||
|
||||
func RegisterJobsPluginsJobInterface(f func(*Server) tjobs.PluginsJobInterface) {
|
||||
jobsPluginsInterface = f
|
||||
}
|
||||
|
||||
var jobsBleveIndexerInterface func(*Server) tjobs.IndexerJobInterface
|
||||
|
||||
func RegisterJobsBleveIndexerInterface(f func(*Server) tjobs.IndexerJobInterface) {
|
||||
jobsBleveIndexerInterface = f
|
||||
}
|
||||
|
||||
var jobsActiveUsersInterface func(*Server) tjobs.ActiveUsersJobInterface
|
||||
|
||||
func RegisterJobsActiveUsersInterface(f func(*Server) tjobs.ActiveUsersJobInterface) {
|
||||
jobsActiveUsersInterface = f
|
||||
}
|
||||
|
||||
var jobsResendInvitationEmailInterface func(*Server) ejobs.ResendInvitationEmailJobInterface
|
||||
|
||||
// RegisterJobsResendInvitationEmailInterface is used to register or initialize the jobsResendInvitationEmailInterface
|
||||
func RegisterJobsResendInvitationEmailInterface(f func(*Server) ejobs.ResendInvitationEmailJobInterface) {
|
||||
jobsResendInvitationEmailInterface = f
|
||||
}
|
||||
|
||||
var jobsCloudInterface func(*Server) ejobs.CloudJobInterface
|
||||
|
||||
func RegisterJobsCloudInterface(f func(*Server) ejobs.CloudJobInterface) {
|
||||
jobsCloudInterface = f
|
||||
}
|
||||
|
||||
var jobsExpiryNotifyInterface func(*Server) tjobs.ExpiryNotifyJobInterface
|
||||
|
||||
func RegisterJobsExpiryNotifyJobInterface(f func(*Server) tjobs.ExpiryNotifyJobInterface) {
|
||||
jobsExpiryNotifyInterface = f
|
||||
}
|
||||
|
||||
var jobsImportProcessInterface func(*Server) tjobs.ImportProcessInterface
|
||||
|
||||
func RegisterJobsImportProcessInterface(f func(*Server) tjobs.ImportProcessInterface) {
|
||||
jobsImportProcessInterface = f
|
||||
}
|
||||
|
||||
var jobsImportDeleteInterface func(*Server) tjobs.ImportDeleteInterface
|
||||
|
||||
func RegisterJobsImportDeleteInterface(f func(*Server) tjobs.ImportDeleteInterface) {
|
||||
jobsImportDeleteInterface = f
|
||||
}
|
||||
|
||||
var jobsExportProcessInterface func(*Server) tjobs.ExportProcessInterface
|
||||
|
||||
func RegisterJobsExportProcessInterface(f func(*Server) tjobs.ExportProcessInterface) {
|
||||
jobsExportProcessInterface = f
|
||||
}
|
||||
|
||||
var jobsExportDeleteInterface func(*Server) tjobs.ExportDeleteInterface
|
||||
|
||||
func RegisterJobsExportDeleteInterface(f func(*Server) tjobs.ExportDeleteInterface) {
|
||||
jobsExportDeleteInterface = f
|
||||
}
|
||||
|
||||
var jobsExtractContentInterface func(*Server) tjobs.ExtractContentInterface
|
||||
|
||||
func RegisterJobsExtractContentInterface(f func(*Server) tjobs.ExtractContentInterface) {
|
||||
jobsExtractContentInterface = f
|
||||
}
|
||||
|
||||
var productNoticesJobInterface func(*Server) tjobs.ProductNoticesJobInterface
|
||||
|
||||
func RegisterProductNoticesJobInterface(f func(*Server) tjobs.ProductNoticesJobInterface) {
|
||||
productNoticesJobInterface = f
|
||||
}
|
||||
|
||||
var ldapInterface func(*Server) einterfaces.LdapInterface
|
||||
|
||||
func RegisterLdapInterface(f func(*Server) einterfaces.LdapInterface) {
|
||||
|
||||
@@ -16,7 +16,7 @@ const (
|
||||
)
|
||||
|
||||
// NotifySessionsExpired is called periodically from the job server to notify any mobile sessions that have expired.
|
||||
func (a *App) NotifySessionsExpired() *model.AppError {
|
||||
func (a *App) NotifySessionsExpired() error {
|
||||
if *a.Config().EmailSettings.SendPushNotifications {
|
||||
pushServer := *a.Config().EmailSettings.PushNotificationServer
|
||||
if license := a.ch.srv.License(); pushServer == model.MHPNS && (license == nil || !*license.Features.MHPNS) {
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestNotifySessionsExpired(t *testing.T) {
|
||||
|
||||
err := th.App.NotifySessionsExpired()
|
||||
// no error, but also no requests sent
|
||||
require.Nil(t, err)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 0, handler.numReqs())
|
||||
})
|
||||
|
||||
@@ -65,8 +65,7 @@ func TestNotifySessionsExpired(t *testing.T) {
|
||||
}
|
||||
|
||||
err := th.App.NotifySessionsExpired()
|
||||
|
||||
require.Nil(t, err)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 2, handler.numReqs())
|
||||
|
||||
expected := []string{"22222", "33333"}
|
||||
|
||||
@@ -20,15 +20,6 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v6/store"
|
||||
)
|
||||
|
||||
type BulkExportOpts struct {
|
||||
IncludeAttachments bool
|
||||
CreateArchive bool
|
||||
}
|
||||
|
||||
// ExportDataDir is the name of the directory were to store additional data
|
||||
// included with the export (e.g. file attachments).
|
||||
const ExportDataDir = "data"
|
||||
|
||||
// We use this map to identify the exportable preferences.
|
||||
// Here we link the preference category and name, to the name of the relevant field in the import struct.
|
||||
var exportablePreferences = map[ComparablePreference]string{{
|
||||
@@ -64,7 +55,7 @@ var exportablePreferences = map[ComparablePreference]string{{
|
||||
}: "EmailInterval",
|
||||
}
|
||||
|
||||
func (a *App) BulkExport(writer io.Writer, outPath string, opts BulkExportOpts) *model.AppError {
|
||||
func (a *App) BulkExport(writer io.Writer, outPath string, opts model.BulkExportOpts) *model.AppError {
|
||||
var zipWr *zip.Writer
|
||||
if opts.CreateArchive {
|
||||
var err error
|
||||
@@ -706,7 +697,7 @@ func (a *App) exportFile(outPath, filePath string, zipWr *zip.Writer) *model.App
|
||||
|
||||
if zipWr != nil {
|
||||
wr, err = zipWr.CreateHeader(&zip.FileHeader{
|
||||
Name: filepath.Join(ExportDataDir, filePath),
|
||||
Name: filepath.Join(model.ExportDataDir, filePath),
|
||||
Method: zip.Store,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -714,7 +705,7 @@ func (a *App) exportFile(outPath, filePath string, zipWr *zip.Writer) *model.App
|
||||
nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
} else {
|
||||
filePath = filepath.Join(outPath, ExportDataDir, filePath)
|
||||
filePath = filepath.Join(outPath, model.ExportDataDir, filePath)
|
||||
if err = os.MkdirAll(filepath.Dir(filePath), 0700); err != nil {
|
||||
return model.NewAppError("exportFileAttachment", "app.export.export_attachment.mkdirall.error",
|
||||
nil, "err="+err.Error(), http.StatusInternalServerError)
|
||||
|
||||
@@ -179,7 +179,7 @@ func TestExportAllUsers(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
|
||||
var b bytes.Buffer
|
||||
err = th1.App.BulkExport(&b, "somePath", BulkExportOpts{})
|
||||
err = th1.App.BulkExport(&b, "somePath", model.BulkExportOpts{})
|
||||
require.Nil(t, err)
|
||||
|
||||
th2 := Setup(t)
|
||||
@@ -227,7 +227,7 @@ func TestExportDMChannel(t *testing.T) {
|
||||
th1.CreateDmChannel(th1.BasicUser2)
|
||||
|
||||
var b bytes.Buffer
|
||||
err := th1.App.BulkExport(&b, "somePath", BulkExportOpts{})
|
||||
err := th1.App.BulkExport(&b, "somePath", model.BulkExportOpts{})
|
||||
require.Nil(t, err)
|
||||
|
||||
channels, nErr := th1.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
|
||||
@@ -268,7 +268,7 @@ func TestExportDMChannel(t *testing.T) {
|
||||
th1.App.PermanentDeleteUser(th1.Context, th1.BasicUser)
|
||||
|
||||
var b bytes.Buffer
|
||||
err := th1.App.BulkExport(&b, "somePath", BulkExportOpts{})
|
||||
err := th1.App.BulkExport(&b, "somePath", model.BulkExportOpts{})
|
||||
require.Nil(t, err)
|
||||
|
||||
th2 := Setup(t).InitBasic()
|
||||
@@ -292,7 +292,7 @@ func TestExportDMChannelToSelf(t *testing.T) {
|
||||
th1.CreateDmChannel(th1.BasicUser)
|
||||
|
||||
var b bytes.Buffer
|
||||
err := th1.App.BulkExport(&b, "somePath", BulkExportOpts{})
|
||||
err := th1.App.BulkExport(&b, "somePath", model.BulkExportOpts{})
|
||||
require.Nil(t, err)
|
||||
|
||||
channels, nErr := th1.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
|
||||
@@ -330,7 +330,7 @@ func TestExportGMChannel(t *testing.T) {
|
||||
th1.CreateGroupChannel(user1, user2)
|
||||
|
||||
var b bytes.Buffer
|
||||
err := th1.App.BulkExport(&b, "somePath", BulkExportOpts{})
|
||||
err := th1.App.BulkExport(&b, "somePath", model.BulkExportOpts{})
|
||||
require.Nil(t, err)
|
||||
|
||||
channels, nErr := th1.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
|
||||
@@ -362,7 +362,7 @@ func TestExportGMandDMChannels(t *testing.T) {
|
||||
th1.CreateGroupChannel(user1, user2)
|
||||
|
||||
var b bytes.Buffer
|
||||
err := th1.App.BulkExport(&b, "somePath", BulkExportOpts{})
|
||||
err := th1.App.BulkExport(&b, "somePath", model.BulkExportOpts{})
|
||||
require.Nil(t, err)
|
||||
|
||||
channels, nErr := th1.App.Srv().Store.Channel().GetAllDirectChannelsForExportAfter(1000, "00000000")
|
||||
@@ -445,7 +445,7 @@ func TestExportDMandGMPost(t *testing.T) {
|
||||
assert.Equal(t, 4, len(posts))
|
||||
|
||||
var b bytes.Buffer
|
||||
appErr := th1.App.BulkExport(&b, "somePath", BulkExportOpts{})
|
||||
appErr := th1.App.BulkExport(&b, "somePath", model.BulkExportOpts{})
|
||||
require.Nil(t, appErr)
|
||||
|
||||
th1.TearDown()
|
||||
@@ -520,7 +520,7 @@ func TestExportPostWithProps(t *testing.T) {
|
||||
require.NotEmpty(t, posts[1].Props)
|
||||
|
||||
var b bytes.Buffer
|
||||
appErr := th1.App.BulkExport(&b, "somePath", BulkExportOpts{})
|
||||
appErr := th1.App.BulkExport(&b, "somePath", model.BulkExportOpts{})
|
||||
require.Nil(t, appErr)
|
||||
|
||||
th1.TearDown()
|
||||
@@ -558,7 +558,7 @@ func TestExportDMPostWithSelf(t *testing.T) {
|
||||
th1.CreatePost(dmChannel)
|
||||
|
||||
var b bytes.Buffer
|
||||
err := th1.App.BulkExport(&b, "somePath", BulkExportOpts{})
|
||||
err := th1.App.BulkExport(&b, "somePath", model.BulkExportOpts{})
|
||||
require.Nil(t, err)
|
||||
|
||||
posts, nErr := th1.App.Srv().Store.Post().GetDirectPostParentsForExportAfter(1000, "0000000")
|
||||
@@ -622,7 +622,7 @@ func TestBulkExport(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer exportFile.Close()
|
||||
|
||||
opts := BulkExportOpts{
|
||||
opts := model.BulkExportOpts{
|
||||
IncludeAttachments: true,
|
||||
CreateArchive: true,
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ func (a *App) ListImports() ([]string, *model.AppError) {
|
||||
results := make([]string, 0, len(imports))
|
||||
for i := 0; i < len(imports); i++ {
|
||||
filename := filepath.Base(imports[i])
|
||||
if !strings.HasSuffix(filename, IncompleteUploadSuffix) {
|
||||
if !strings.HasSuffix(filename, model.IncompleteUploadSuffix) {
|
||||
results = append(results, filename)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,7 +489,7 @@ func TestImportBulkImportWithAttachments(t *testing.T) {
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.MaxUsersPerTeam = model.NewInt(1000) })
|
||||
|
||||
appErr, _ := th.App.BulkImportWithPath(th.Context, jsonFile, importZipReader, false, 1, ExportDataDir)
|
||||
appErr, _ := th.App.BulkImportWithPath(th.Context, jsonFile, importZipReader, false, 1, model.ExportDataDir)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
adminUser, appErr := th.App.GetUserByUsername("sysadmin")
|
||||
|
||||
@@ -973,7 +973,7 @@ func (a *OpenTracingAppLayer) BuildSamlMetadataObject(idpMetadata []byte) (*mode
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) BulkExport(writer io.Writer, outPath string, opts app.BulkExportOpts) *model.AppError {
|
||||
func (a *OpenTracingAppLayer) BulkExport(writer io.Writer, outPath string, opts model.BulkExportOpts) *model.AppError {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.BulkExport")
|
||||
|
||||
@@ -11742,7 +11742,7 @@ func (a *OpenTracingAppLayer) NotifyAndSetWarnMetricAck(warnMetricId string, sen
|
||||
return resultVar0
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) NotifySessionsExpired() *model.AppError {
|
||||
func (a *OpenTracingAppLayer) NotifySessionsExpired() error {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.NotifySessionsExpired")
|
||||
|
||||
|
||||
150
app/server.go
150
app/server.go
@@ -45,13 +45,25 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v6/config"
|
||||
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/jobs"
|
||||
"github.com/mattermost/mattermost-server/v6/jobs/active_users"
|
||||
"github.com/mattermost/mattermost-server/v6/jobs/expirynotify"
|
||||
"github.com/mattermost/mattermost-server/v6/jobs/export_delete"
|
||||
"github.com/mattermost/mattermost-server/v6/jobs/export_process"
|
||||
"github.com/mattermost/mattermost-server/v6/jobs/extract_content"
|
||||
"github.com/mattermost/mattermost-server/v6/jobs/import_delete"
|
||||
"github.com/mattermost/mattermost-server/v6/jobs/import_process"
|
||||
"github.com/mattermost/mattermost-server/v6/jobs/migrations"
|
||||
"github.com/mattermost/mattermost-server/v6/jobs/product_notices"
|
||||
"github.com/mattermost/mattermost-server/v6/jobs/resend_invitation_email"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/plugin/scheduler"
|
||||
"github.com/mattermost/mattermost-server/v6/services/awsmeter"
|
||||
"github.com/mattermost/mattermost-server/v6/services/cache"
|
||||
"github.com/mattermost/mattermost-server/v6/services/httpservice"
|
||||
"github.com/mattermost/mattermost-server/v6/services/remotecluster"
|
||||
"github.com/mattermost/mattermost-server/v6/services/searchengine"
|
||||
"github.com/mattermost/mattermost-server/v6/services/searchengine/bleveengine"
|
||||
"github.com/mattermost/mattermost-server/v6/services/searchengine/bleveengine/indexer"
|
||||
"github.com/mattermost/mattermost-server/v6/services/sharedchannel"
|
||||
"github.com/mattermost/mattermost-server/v6/services/telemetry"
|
||||
"github.com/mattermost/mattermost-server/v6/services/timezones"
|
||||
@@ -1862,72 +1874,110 @@ func (ch *Channels) ClientConfigHash() string {
|
||||
|
||||
func (s *Server) initJobs() {
|
||||
s.Jobs = jobs.NewJobServer(s, s.Store, s.Metrics)
|
||||
s.Jobs.InitWorkers()
|
||||
s.Jobs.InitSchedulers()
|
||||
|
||||
if jobsDataRetentionJobInterface != nil {
|
||||
s.Jobs.DataRetentionJob = jobsDataRetentionJobInterface(s)
|
||||
builder := jobsDataRetentionJobInterface(s)
|
||||
s.Jobs.RegisterJobType(model.JobTypeDataRetention, builder.MakeWorker(), builder.MakeScheduler())
|
||||
}
|
||||
|
||||
if jobsMessageExportJobInterface != nil {
|
||||
s.Jobs.MessageExportJob = jobsMessageExportJobInterface(s)
|
||||
builder := jobsMessageExportJobInterface(s)
|
||||
s.Jobs.RegisterJobType(model.JobTypeMessageExport, builder.MakeWorker(), builder.MakeScheduler())
|
||||
}
|
||||
|
||||
if jobsElasticsearchAggregatorInterface != nil {
|
||||
s.Jobs.ElasticsearchAggregator = jobsElasticsearchAggregatorInterface(s)
|
||||
builder := jobsElasticsearchAggregatorInterface(s)
|
||||
s.Jobs.RegisterJobType(model.JobTypeElasticsearchPostAggregation, builder.MakeWorker(), builder.MakeScheduler())
|
||||
}
|
||||
|
||||
if jobsElasticsearchIndexerInterface != nil {
|
||||
s.Jobs.ElasticsearchIndexer = jobsElasticsearchIndexerInterface(s)
|
||||
}
|
||||
if jobsBleveIndexerInterface != nil {
|
||||
s.Jobs.BleveIndexer = jobsBleveIndexerInterface(s)
|
||||
}
|
||||
if jobsMigrationsInterface != nil {
|
||||
s.Jobs.Migrations = jobsMigrationsInterface(s)
|
||||
builder := jobsElasticsearchIndexerInterface(s)
|
||||
s.Jobs.RegisterJobType(model.JobTypeElasticsearchPostIndexing, builder.MakeWorker(), nil)
|
||||
}
|
||||
|
||||
if jobsLdapSyncInterface != nil {
|
||||
s.Jobs.LdapSync = jobsLdapSyncInterface(s)
|
||||
}
|
||||
if jobsPluginsInterface != nil {
|
||||
s.Jobs.Plugins = jobsPluginsInterface(s)
|
||||
}
|
||||
if jobsExpiryNotifyInterface != nil {
|
||||
s.Jobs.ExpiryNotify = jobsExpiryNotifyInterface(s)
|
||||
}
|
||||
if productNoticesJobInterface != nil {
|
||||
s.Jobs.ProductNotices = productNoticesJobInterface(s)
|
||||
}
|
||||
if jobsImportProcessInterface != nil {
|
||||
s.Jobs.ImportProcess = jobsImportProcessInterface(s)
|
||||
}
|
||||
if jobsImportDeleteInterface != nil {
|
||||
s.Jobs.ImportDelete = jobsImportDeleteInterface(s)
|
||||
}
|
||||
if jobsExportDeleteInterface != nil {
|
||||
s.Jobs.ExportDelete = jobsExportDeleteInterface(s)
|
||||
}
|
||||
|
||||
if jobsExportProcessInterface != nil {
|
||||
s.Jobs.ExportProcess = jobsExportProcessInterface(s)
|
||||
}
|
||||
|
||||
if jobsExportProcessInterface != nil {
|
||||
s.Jobs.ExportProcess = jobsExportProcessInterface(s)
|
||||
}
|
||||
|
||||
if jobsActiveUsersInterface != nil {
|
||||
s.Jobs.ActiveUsers = jobsActiveUsersInterface(s)
|
||||
builder := jobsLdapSyncInterface(s)
|
||||
s.Jobs.RegisterJobType(model.JobTypeLdapSync, builder.MakeWorker(), builder.MakeScheduler())
|
||||
}
|
||||
|
||||
if jobsCloudInterface != nil {
|
||||
s.Jobs.Cloud = jobsCloudInterface(s)
|
||||
builder := jobsCloudInterface(s)
|
||||
s.Jobs.RegisterJobType(model.JobTypeCloud, builder.MakeWorker(), builder.MakeScheduler())
|
||||
}
|
||||
|
||||
if jobsResendInvitationEmailInterface != nil {
|
||||
s.Jobs.ResendInvitationEmails = jobsResendInvitationEmailInterface(s)
|
||||
}
|
||||
s.Jobs.RegisterJobType(
|
||||
model.JobTypeBlevePostIndexing,
|
||||
indexer.MakeWorker(s.Jobs, s.SearchEngine.BleveEngine.(*bleveengine.BleveEngine)),
|
||||
nil,
|
||||
)
|
||||
|
||||
if jobsExtractContentInterface != nil {
|
||||
s.Jobs.ExtractContent = jobsExtractContentInterface(s)
|
||||
}
|
||||
s.Jobs.RegisterJobType(
|
||||
model.JobTypeMigrations,
|
||||
migrations.MakeWorker(s.Jobs, s.Store),
|
||||
migrations.MakeScheduler(s.Jobs, s.Store),
|
||||
)
|
||||
|
||||
s.Jobs.InitWorkers()
|
||||
s.Jobs.InitSchedulers()
|
||||
s.Jobs.RegisterJobType(
|
||||
model.JobTypePlugins,
|
||||
scheduler.MakeWorker(s.Jobs, New(ServerConnector(s.Channels()))),
|
||||
scheduler.MakeScheduler(s.Jobs),
|
||||
)
|
||||
|
||||
s.Jobs.RegisterJobType(
|
||||
model.JobTypeExpiryNotify,
|
||||
expirynotify.MakeWorker(s.Jobs, New(ServerConnector(s.Channels())).NotifySessionsExpired),
|
||||
expirynotify.MakeScheduler(s.Jobs),
|
||||
)
|
||||
|
||||
s.Jobs.RegisterJobType(
|
||||
model.JobTypeProductNotices,
|
||||
product_notices.MakeWorker(s.Jobs, New(ServerConnector(s.Channels()))),
|
||||
product_notices.MakeScheduler(s.Jobs),
|
||||
)
|
||||
|
||||
s.Jobs.RegisterJobType(
|
||||
model.JobTypeImportProcess,
|
||||
import_process.MakeWorker(s.Jobs, New(ServerConnector(s.Channels()))),
|
||||
nil,
|
||||
)
|
||||
|
||||
s.Jobs.RegisterJobType(
|
||||
model.JobTypeImportDelete,
|
||||
import_delete.MakeWorker(s.Jobs, New(ServerConnector(s.Channels())), s.Store),
|
||||
import_delete.MakeScheduler(s.Jobs),
|
||||
)
|
||||
|
||||
s.Jobs.RegisterJobType(
|
||||
model.JobTypeExportDelete,
|
||||
export_delete.MakeWorker(s.Jobs, New(ServerConnector(s.Channels()))),
|
||||
export_delete.MakeScheduler(s.Jobs),
|
||||
)
|
||||
|
||||
s.Jobs.RegisterJobType(
|
||||
model.JobTypeExportProcess,
|
||||
export_process.MakeWorker(s.Jobs, New(ServerConnector(s.Channels()))),
|
||||
nil,
|
||||
)
|
||||
|
||||
s.Jobs.RegisterJobType(
|
||||
model.JobTypeActiveUsers,
|
||||
active_users.MakeWorker(s.Jobs, s.Store, func() einterfaces.MetricsInterface { return s.Metrics }),
|
||||
active_users.MakeScheduler(s.Jobs),
|
||||
)
|
||||
|
||||
s.Jobs.RegisterJobType(
|
||||
model.JobTypeResendInvitationEmail,
|
||||
resend_invitation_email.MakeWorker(s.Jobs, New(ServerConnector(s.Channels())), s.Store, s.telemetryService),
|
||||
nil,
|
||||
)
|
||||
|
||||
s.Jobs.RegisterJobType(
|
||||
model.JobTypeExtractContent,
|
||||
extract_content.MakeWorker(s.Jobs, New(ServerConnector(s.Channels())), s.Store),
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
func (s *Server) TelemetryId() string {
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
)
|
||||
|
||||
const minFirstPartSize = 5 * 1024 * 1024 // 5MB
|
||||
const IncompleteUploadSuffix = ".tmp"
|
||||
|
||||
func (a *App) runPluginsHook(c *request.Context, info *model.FileInfo, file io.Reader) *model.AppError {
|
||||
pluginsEnvironment := a.GetPluginsEnvironment()
|
||||
@@ -195,7 +194,7 @@ func (a *App) UploadData(c *request.Context, us *model.UploadSession, rd io.Read
|
||||
|
||||
uploadPath := us.Path
|
||||
if us.Type == model.UploadTypeImport {
|
||||
uploadPath += IncompleteUploadSuffix
|
||||
uploadPath += model.IncompleteUploadSuffix
|
||||
}
|
||||
|
||||
// make sure it's not possible to upload more data than what is expected.
|
||||
|
||||
Ссылка в новой задаче
Block a user