Documentation ¶
Index ¶
- Constants
- func NewDatabase() *mongo.Database
- type Config
- type ConfigStore
- type Job
- type JobStore
- type LockStore
- type Role
- type RoleStore
- type Task
- type TaskStore
- type Time
- func (t Time) Format(layout string) string
- func (t Time) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (t Time) MarshalJSON() (b []byte, err error)
- func (t Time) String() string
- func (t *Time) UnmarshalBSONValue(bt bsontype.Type, data []byte) error
- func (t *Time) UnmarshalJSON(data []byte) (err error)
- type User
- type UserStore
Constants ¶
View Source
const ( UserStatusBlocked = 0 UserStatusNormal = 1 )
Variables ¶
This section is empty.
Functions ¶
func NewDatabase ¶
Types ¶
type ConfigStore ¶
type ConfigStore interface { Find(id string) (data.Options, error) Save(id string, opts data.Options) error }
func NewConfigStore ¶
func NewConfigStore(db *mongo.Database) ConfigStore
type Job ¶
type Job struct { Id primitive.ObjectID `json:"id" bson:"_id"` Task string `json:"task" bson:"task"` Handler string `json:"handler" bson:"handler"` Scheduler string `json:"scheduler" bson:"scheduler"` Mode int32 `json:"mode" bson:"mode"` // 0-Auto, 1-Manual Args data.Options `json:"args" bson:"args"` FireTime Time `json:"fire_time" bson:"fire_time"` Dispatch struct { Status int32 `json:"status" bson:"status"` // 0-Unknown,1-Success,2-Failed Time *Time `json:"time,omitempty" bson:"time,omitempty"` Error string `json:"error,omitempty" bson:"error,omitempty"` } `json:"dispatch" bson:"dispatch"` Execute struct { Status int32 `json:"status" bson:"status"` // 0-Unknown,1-Success,2-Failed Error string `json:"error,omitempty" bson:"error,omitempty"` StartTime *Time `json:"start_time,omitempty" bson:"start_time,omitempty"` EndTime *Time `json:"end_time,omitempty" bson:"end_time,omitempty"` } `json:"execute" bson:"execute"` }
type JobStore ¶
type JobStore interface { Find(id string) (*Job, error) Search(task string, mode int32, dispatchStatus, executeStatus int32, pageIndex, pageSize int64) (jobs []*Job, total int64, err error) Create(job *Job) error ModifyDispatch(id string, success bool, error string) error ModifyExecute(id string, success bool, error string, start, end time.Time) error CreateIndexes(ctx context.Context) error Count(ctx context.Context) (int64, error) }
func NewJobStore ¶
type LockStore ¶
type LockStore interface { Create(key, value string) error Delete(key string) error CreateIndexes(ctx context.Context) error }
func NewLockStore ¶
type RoleStore ¶
type RoleStore interface { Create(r *Role) error Modify(role *Role) error Find(id string) (*Role, error) Search(name string) ([]*Role, error) Delete(id string) error }
func NewRoleStore ¶
type Task ¶
type Task struct { Name string `json:"name" bson:"_id" valid:"required"` Runner string `json:"runner" bson:"runner" valid:"required"` Handler string `json:"handler,omitempty" bson:"handler,omitempty"` Args data.Options `json:"args" bson:"args"` Triggers []string `json:"triggers" bson:"triggers"` Description string `json:"desc,omitempty" bson:"desc,omitempty"` Enabled bool `json:"enabled" bson:"enabled"` Maintainers []string `json:"maintainers" bson:"maintainers"` Alerts []string `json:"alerts" bson:"alerts"` ModifyTime Time `json:"modify_time" bson:"modify_time"` }
type TaskStore ¶
type TaskStore interface { Find(name string) (*Task, error) Delete(name string) error Create(t *Task) error Modify(t *Task) error Search(name, runner string, pageIndex, pageSize int64) (tasks []*Task, total int64, err error) GetState() (modify time.Time, count int64, err error) FetchAll(enabled bool) ([]*Task, error) Count(ctx context.Context) (int64, error) }
func NewTaskStore ¶
type Time ¶
func (Time) MarshalJSON ¶
func (*Time) UnmarshalBSONValue ¶
func (*Time) UnmarshalJSON ¶
type User ¶
type User struct { Id string `json:"id" bson:"_id"` Name string `json:"name" bson:"name" valid:"required"` LoginName string `json:"login_name" bson:"login_name" valid:"required"` Roles []string `json:"roles" bson:"roles"` Email string `json:"email,omitempty" bson:"email" valid:"email"` Phone string `json:"phone,omitempty" bson:"phone"` Wecom string `json:"wecom,omitempty" bson:"wecom"` Admin bool `json:"admin" bson:"admin"` Status int32 `json:"status" bson:"status"` // 0-禁用, 1-正常 Password string `json:"-" bson:"password"` Salt string `json:"-" bson:"salt" mongo:"create:true,update:false,deep:false"` CreateTime time.Time `json:"create_time" bson:"create_time"` ModifyTime time.Time `json:"modify_time" bson:"modify_time"` }
type UserStore ¶
type UserStore interface { Create(u *User) error Modify(t *User) error ModifyProfile(t *User) error Find(id string) (u *User, err error) FindByName(loginName string) (*User, error) Search(name, loginName, filter string, pageIndex, pageSize int64) (users []*User, total int64, err error) Fetch(ids []string) (users []*User, err error) SetPassword(id string, password, salt string) error SetStatus(id string, status int32) error Count(ctx context.Context) (int64, error) CreateIndexes(ctx context.Context) error }
func NewUserStore ¶
Click to show internal directories.
Click to hide internal directories.