app

package
v0.0.0-...-f8b5f28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

# Some idea: # Set a trash bin and then permanently deleted? -- can use the build-in delete(just mark)

Implement notes: Use api to get information, DON't use database directly But cleanng work will do directly with database anyway. Investigate API, to find the database operation

Mattermost job system memo v5.35

Jobserver: Like a platform providing tools
Watch:     Poll and notify Works every 15 secs
           Check the job DB and find any pending jobs
           send the job to specific job channel( return from Worker.JobChannel())
Scheduler: Schedule the next exection time
           Put the job in DB as pending status, this must be implemented in ScheduleJob() using Jobserver.CreateJob
Worker:    Execute job. Wait until any job put in JobChannel()

Initialization flow: Server cmd - run-server:

a.NewServer
      s.initEntprise
      s.initJobs
fakeapp.initServer
      a.initEnterprise
      a.initJobs
          a.srv.jobs.initWorks()
              a.srv.jobs.MakeWatcher()
          a.src.jobs.initSchedules()
          s.runjobs
              s.js.StartWorkers()
                   workers.start() + watch.start()
              s.js.StartSchedulers()

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoTeam    = errors.New("can not found team.")
	ErrNoChannel = errors.New("can not found channel.")
	ErrNoUser    = errors.New("can not found user.")
	ErrRequired  = errors.New("require setting.")
	ErrConfilct  = errors.New("conflict setting.")
)
View Source
var (
	DAY0         = Days{0}
	SWITCH_FALSE = Switch{false}
	SWITCH_TRUE  = Switch{true}
)

Functions

This section is empty.

Types

type Channel

type Channel struct {
	Settings *Settings `yaml:"settings,omitempty"`
}

type ChannelRes

type ChannelRes struct {
	Id    string
	Name  string
	Error error
	Stats Stats
}

type Channels

type Channels map[string]*Channel

type ChannelsRes

type ChannelsRes map[string]ChannelRes

type Days

type Days struct {
	Value float32 `yaml:"value"`
}

type ExpanedPolicyWithId

type ExpanedPolicyWithId Policy

type File

type File struct {
	Path string
	Size int
}

type Options

type Options struct {
	Before int64
}

type Policy

type Policy struct {
	//nil means using default
	Settings *Settings `yaml:"settings,omitempty"`
	Teams    Teams     `yaml:"teams,omitempty"`
	Users    *Users    `yaml:"users,omitempty"`
}

type PolicyCtrl

type PolicyCtrl struct {
	Policy Policy
	// contains filtered or unexported fields
}

func (*PolicyCtrl) ExpandPolicyAndNormalize

func (pctl *PolicyCtrl) ExpandPolicyAndNormalize() (*ExpanedPolicyWithId, error)

ExpandPolicyAndNormalize expand the policy to individual unit and normalize the result. Normalized result fills all the field settings, which means all the teams/channels/user which will be pruned should be filled with all fields.

Expandition flow: - If current Persist* is not nil and false, use the Day* vale( Day* must be not zero) - if current Persist* is not nil and true, set Persist* = true, leave Day* nil - if current Perist* is nil, look levels up until the first Perist* is not nil -- if Perist* == true, set true, and leave Day* nil -- if Perist* == false, set false, and set Days* as that value( must not be zero) -- if all Persit* is true, don't append the result

Note: - Result is is a map with Id( not name)

func (*PolicyCtrl) GetPolicy

func (pctl *PolicyCtrl) GetPolicy() Policy

func (*PolicyCtrl) LoadFromConfig

func (pctl *PolicyCtrl) LoadFromConfig() error

func (*PolicyCtrl) LoadFromYaml

func (pctl *PolicyCtrl) LoadFromYaml(yamlStr string) error

LoadFromYaml load and normalize the result.

For root node, nil means false, should create a node. For non-root node, nil means look levels up for that field.

If Days* is inputed but Persist* is nil, set Persist* = false If Days* is inputed(!= nil, or value != 0) but Persist* == true, non-sense, error If Days* is not inputed(nil), but Persis* == false, error

type PolicyService

type PolicyService interface {
	LoadFromConfig() error
	LoadFromYaml(yamlStr string) error
	ExpandPolicyAndNormalize() (*ExpanedPolicyWithId, error)
	GetPolicy() Policy
}

func NewPolicyService

func NewPolicyService(apiClient *pluginapi.Client, cl config.Service, pstore PruneStore) PolicyService

type PruneService

type PruneService interface {
	Start() (*Result, error)
}

func NewPruneService

func NewPruneService(ps PruneStore, api *pluginapi.Client, cl config.Service, logger bot.Logger, poster bot.Poster) PruneService

type PruneStore

type PruneStore interface {
	CutThreads(chid string, opt Options) ([]*model.Post, error)
	CutRoots(chid string, opt Options) ([]*model.Post, error)
	CutDeletedRoots(chid string, opt Options) ([]*model.Post, error)
	SweepThreads() ([]*model.Post, error)
	SweepReactions() ([]*model.Reaction, error)
	SweepPreferences() ([]*model.Preference, error)
	SweepFileInfos() ([]*model.FileInfo, error)
	SweepFiles() ([]File, error)

	//copied from mattermost-server channel store( MM_ChannelStore_GetAll)
	GetAllChannelsForTeam(teamID string) ([]*model.Channel, error)
}

type Result

type Result struct {
	Teams            TeamsRes
	Users            UsersRes
	AllTeamsChannels ChannelsRes
	AllUsersChannels UsersRes
	Sweeps           map[string]Sweep
}

type Settings

type Settings struct {
	PersistNormal  *Switch `yaml:"persist_normal"`
	PersistDeleted *Switch `yaml:"persist_deleted"`
	DaysOfPrune    *Days   `yaml:"days_of_prune"`
	DaysOfDeleted  *Days   `yaml:"days_of_deleted"`
	//OnlyThreadPruned prune only threads.
	//context free of Persist*
	OnlyThreadPruned *Switch `yaml:"only_thread"`
}

if nil, use Settings 1 level up if root's setting is nil, no deletetion is default if Persist* = true, then Days* will always be 0. they are paires

Deleted posts and Non-Deleted posts are seperated.

if OnlyThreadPruned then prune only thread else only roots

type Stats

type Stats struct {
	CutThreads       int
	CutRoots         int
	CutDeletedRoots  int
	SweepThreads     int
	SweepReactions   int
	SweepPreferences int
	SweepFileInfos   int
	SweepFilesPath   StatsFile
	SweepFilesThumb  StatsFile
	SweepFilesPrev   StatsFile
}

type StatsFile

type StatsFile struct {
	Count int
	Size  int
}

type Sweep

type Sweep struct {
	Error error
	Count int
	Left  int
}

type SweepFiles

type SweepFiles struct {
	Error     error
	Path      StatsFile
	LeftPath  StatsFile
	Thumbnail StatsFile
	LeftThumb StatsFile
	Preview   StatsFile
	LeftPrev  StatsFile
}

type Switch

type Switch struct {
	Value bool `yaml:"value"`
}

type Team

type Team struct {
	Settings *Settings `yaml:"settings,omitempty"`
	Channels Channels  `yaml:"channels,omitempty"`
}

type TeamRes

type TeamRes struct {
	Id       string
	Name     string
	Error    error
	Channels ChannelsRes
}

type Teams

type Teams map[string]*Team

type TeamsRes

type TeamsRes map[string]TeamRes

type UserRes

type UserRes struct {
	Id    string
	Names []string
	Error error
	Stats Stats
}

type Users

type Users Team

type UsersRes

type UsersRes map[string]UserRes

Directories

Path Synopsis
Package mock_app is a generated GoMock package.
Package mock_app is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL