siyouyunsdk

package module
v0.3.30 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

README

siyouyun_sdk

Siyouyun FaaS Service SDK

Documentation

Index

Constants

View Source
const (
	FileEventAdd = iota + 1
	FileEventDelete
)

文件事件类型,文件创建与文件删除

View Source
const (
	AppCodeEnvKey = "APPCODE"
)

Variables

This section is empty.

Functions

func Alive added in v0.3.2

func Alive(ctx iris.Context)

Alive 激活函数接口

func EnableMessage added in v0.2.20

func EnableMessage(desc string, handler func(appfs *AppFS, content string) (reply bool, replyContent string, replyToUUID bool)) error

EnableMessage 开启消息机器人 desc:

消息机器人的功能描述

handler func(content string) (reply bool, replyContent string, replyToUUID bool):

入参:
	- content 用户发送到机器人的消息正文
返回值:
	- reply 		:	是否需要回复
	- replyContent	:	回复的正文
	- replyToUUID	:	回复时是否引用用户消息

func ListenMsg added in v0.2.20

func ListenMsg(mh *MessageHandlerStruct)

Types

type Ability added in v0.2.3

type Ability struct {
	KV       *KV
	FFmpeg   *FFmpeg
	Schedule *Schedule
	Message  *Message
}

type AppFS added in v0.1.22

type AppFS struct {
	*Ability
	// contains filtered or unexported fields
}

func (*AppFS) Chtimes added in v0.1.25

func (afs *AppFS) Chtimes(path string, atime time.Time, mtime time.Time) error

Chtimes 修改文件时间

func (*AppFS) Destroy added in v0.1.24

func (afs *AppFS) Destroy()

func (*AppFS) EnsureDirExist added in v0.1.22

func (afs *AppFS) EnsureDirExist(ps ...string)

EnsureDirExist 确保目录存在

func (*AppFS) Exec added in v0.2.15

func (afs *AppFS) Exec(f func(*gorm.DB) error) error

func (*AppFS) FileExists added in v0.1.22

func (afs *AppFS) FileExists(path string) bool

FileExists 文件是否存在

func (*AppFS) InodeToFileInfo added in v0.1.22

func (afs *AppFS) InodeToFileInfo(inode int64) *sdkdto.FileInfoRes

InodeToFileInfo inode转fileInfo

func (*AppFS) InodeToPath added in v0.1.22

func (afs *AppFS) InodeToPath(inode int64) string

InodeToPath inode转path

func (*AppFS) InodesToFileInfos added in v0.1.22

func (afs *AppFS) InodesToFileInfos(inodes ...int64) map[int64]sdkdto.FileInfoRes

InodesToFileInfos inodes转fileInfos

func (*AppFS) MkdirAll added in v0.1.22

func (afs *AppFS) MkdirAll(path string) error

MkdirAll 递归创建目录

func (*AppFS) Open added in v0.1.22

func (afs *AppFS) Open(path string) (*SyyFile, error)

Open 打开文件

func (*AppFS) OpenFile added in v0.1.22

func (afs *AppFS) OpenFile(path string, flag int, perm os.FileMode) (*SyyFile, error)

OpenFile 打开或创建文件

func (*AppFS) PathToInode added in v0.1.22

func (afs *AppFS) PathToInode(path string) int64

PathToInode path转inode

func (*AppFS) Remove added in v0.1.22

func (afs *AppFS) Remove(path string) error

Remove 删除文件

func (*AppFS) Rename added in v0.1.22

func (afs *AppFS) Rename(oldPath, newPath string) error

Rename 重命名文件

type AppStruct added in v0.1.23

type AppStruct struct {
	AppCode  string
	Api      SiyouFaasApi
	AppInfo  *sdkentity.AppRegisterInfo
	Event    *EventHolder
	Schedule *ScheduleHandler
	Model    []interface{}

	DB *gorm.DB
}
var App *AppStruct

func NewApp

func NewApp() *AppStruct

func (*AppStruct) NewAppFSFromCtx added in v0.1.23

func (a *AppStruct) NewAppFSFromCtx(ctx iris.Context) *AppFS

func (*AppStruct) NewAppFSFromUserNamespace added in v0.1.23

func (a *AppStruct) NewAppFSFromUserNamespace(un *utils.UserGroupNamespace) *AppFS

func (*AppStruct) NewFSFromCtx added in v0.1.23

func (a *AppStruct) NewFSFromCtx(ctx iris.Context) *FS

func (*AppStruct) NewFSFromUserNamespace added in v0.1.23

func (a *AppStruct) NewFSFromUserNamespace(un *utils.UserGroupNamespace) *FS

func (*AppStruct) WithEventHolder added in v0.1.23

func (a *AppStruct) WithEventHolder()

WithEventHolder 初始化事件监听器

func (*AppStruct) WithModel added in v0.1.24

func (a *AppStruct) WithModel(models ...interface{})

func (*AppStruct) WithScheduleEvent added in v0.2.29

func (a *AppStruct) WithScheduleEvent()

type ConsumeStatus added in v0.2.7

type ConsumeStatus int
const (
	ConsumeSuccess ConsumeStatus = iota + 1
	ConsumeRetry
	ConsumeFail
)

type EventFS added in v0.1.21

type EventFS struct {
	EventFileInode int64
	FS             *FS
	AppFS          *AppFS
	*Ability
}

func (*EventFS) Destroy added in v0.1.24

func (efs *EventFS) Destroy()

func (*EventFS) Exec added in v0.2.15

func (efs *EventFS) Exec(f func(*gorm.DB) error) error

func (*EventFS) OpenEventFile added in v0.1.21

func (efs *EventFS) OpenEventFile() (*SyyFile, error)

OpenEventFile 打开事件相关文件

type EventHolder added in v0.1.7

type EventHolder struct {
	// contains filtered or unexported fields
}

func (*EventHolder) Listen added in v0.1.7

func (e *EventHolder) Listen()

Listen 开始监听器工作

func (*EventHolder) SetPrefer added in v0.1.7

func (e *EventHolder) SetPrefer(options ...PreferOptions)

SetPrefer 设置偏好与回调函数

type FFmpeg added in v0.2.3

type FFmpeg struct {
	*gateway.FFmpegOSApi
}

func (*FFmpeg) GetBasicInfo added in v0.2.3

func (ff *FFmpeg) GetBasicInfo(parentPath, name string) (*sdkdto.FFmpegBasicInfo, error)

func (*FFmpeg) GetDetailInfo added in v0.2.3

func (ff *FFmpeg) GetDetailInfo(parentPath, name string) (*sdkdto.FFProbeInfo, error)

type FS added in v0.1.7

type FS struct {
	AppCodeName string
	*Ability

	App *AppStruct
	UGN *utils.UserGroupNamespace
	// contains filtered or unexported fields
}

FS fs

func (*FS) Chtimes added in v0.1.25

func (fs *FS) Chtimes(path string, atime time.Time, mtime time.Time) error

Chtimes 修改文件时间

func (*FS) Destroy added in v0.1.24

func (fs *FS) Destroy()

func (*FS) EnsureDirExist added in v0.1.16

func (fs *FS) EnsureDirExist(ps ...string)

EnsureDirExist 确保目录存在

func (*FS) Exec added in v0.1.19

func (fs *FS) Exec(f func(*gorm.DB) error) error

Exec fs执行sql

func (*FS) FileExists added in v0.1.16

func (fs *FS) FileExists(path string) bool

FileExists 文件是否存在

func (*FS) InodeToFileInfo added in v0.1.16

func (fs *FS) InodeToFileInfo(inode int64) *sdkdto.FileInfoRes

InodeToFileInfo inode转fileInfo

func (*FS) InodeToPath added in v0.1.16

func (fs *FS) InodeToPath(inode int64) string

InodeToPath inode转path

func (*FS) InodesToFileInfos added in v0.1.16

func (fs *FS) InodesToFileInfos(inodes ...int64) map[int64]sdkdto.FileInfoRes

InodesToFileInfos inodes转fileInfos

func (*FS) MkdirAll added in v0.1.21

func (fs *FS) MkdirAll(path string) error

MkdirAll 递归创建目录

func (*FS) NewFFmpeg added in v0.2.3

func (fs *FS) NewFFmpeg() *FFmpeg

func (*FS) NewKV added in v0.2.3

func (fs *FS) NewKV() *KV

func (*FS) NewSchedule added in v0.2.29

func (fs *FS) NewSchedule() *Schedule

func (*FS) Open added in v0.1.7

func (fs *FS) Open(path string) (*SyyFile, error)

Open 打开文件

func (*FS) OpenFile added in v0.1.21

func (fs *FS) OpenFile(path string, flag int, perm os.FileMode) (*SyyFile, error)

OpenFile 打开或创建文件

func (*FS) PathToInode added in v0.1.16

func (fs *FS) PathToInode(path string) int64

PathToInode path转inode

func (*FS) Remove added in v0.1.21

func (fs *FS) Remove(path string) error

Remove 删除文件

func (*FS) Rename added in v0.1.21

func (fs *FS) Rename(oldPath, newPath string) error

Rename 重命名文件

type FileEvent added in v0.1.7

type FileEvent struct {
	Inode  int64                    `json:"inode,omitempty"`
	Action int                      `json:"action,omitempty"`
	UGN    utils.UserGroupNamespace `json:"ugn"`
}

type FileType added in v0.1.7

type FileType string
const (
	FileTypeAll      FileType = "all"
	FileTypeText     FileType = "text"
	FileTypeImage    FileType = "image"
	FileTypeAudio    FileType = "audio"
	FileTypeVideo    FileType = "video"
	FileTypeMessage  FileType = "message"
	FileTypeCompress FileType = "compress"

	FileTypeImageVideo FileType = "image-video"
	FileTypeDoc        FileType = "doc"
	FileTypeBt         FileType = "bt"
	FileTypeEbook      FileType = "ebook"
	FileTypeSoftware   FileType = "software"
	FileTypeOther      FileType = "other"
)

偏好设置可以关注的文件类型,上半部分为独立类型文件,下半部分为混合类型文件

type KV added in v0.2.3

type KV struct {
	*gateway.KVCoreApi
}

func (*KV) DeleteKV added in v0.2.3

func (kv *KV) DeleteKV(kvType, key string) error

func (*KV) GetKV added in v0.2.3

func (kv *KV) GetKV(kvType, key string) (*sdkdto.KV, bool)

func (*KV) PutKV added in v0.2.3

func (kv *KV) PutKV(kvType, key, value string) error

type Message added in v0.2.47

type Message struct {
}

func (*Message) SendMsg added in v0.2.47

func (m *Message) SendMsg(un *utils.UserGroupNamespace, content string) error

SendMsg 发送消息给用户,只有权限发送给拥有此app的用户 un : 用户与空间 content : 消息正文

type MessageEvent added in v0.2.20

type MessageEvent struct {
	UGN       utils.UserGroupNamespace `json:"ugn"`
	UUID      string                   `json:"uuid"`
	Content   string                   `json:"content"`
	SessionId string                   `json:"sessionId"`

	SendByAdmin bool `json:"sendByAdmin"`
}

MessageEvent 消息在事件中传递的结构

type MessageHandlerStruct added in v0.2.20

type MessageHandlerStruct struct {
	RobotCode string                                                                                 `json:"robotCode"`
	RobotDesc string                                                                                 `json:"robotDesc"`
	Handler   func(appfs *AppFS, content string) (reply bool, replyContent string, replyToUUID bool) `json:"-"`
}

type PreferOptions added in v0.1.7

type PreferOptions struct {
	FileType      FileType                                  `json:"fileType"`      // 文件类型
	FileEventType int                                       `json:"fileEventType"` // 事件类型
	FollowDirs    []string                                  `json:"followDirs"`    // 关注目录(不设置默认所有)
	Description   string                                    `json:"description"`   // 描述
	Priority      TaskLevel                                 `json:"priority"`      // 优先级(资源占用等级)
	Handler       func(fs *EventFS) (ConsumeStatus, string) `json:"-"`             // 处理器
}

PreferOptions 事件偏好选项

type Schedule added in v0.2.29

type Schedule struct {
	*gateway.ScheduleApi
}

func (*Schedule) AddCronScheduleEvent added in v0.2.29

func (s *Schedule) AddCronScheduleEvent(name string, payload []byte, c string) (err error, eventId *int64)

func (*Schedule) AddOnceScheduleEvent added in v0.2.29

func (s *Schedule) AddOnceScheduleEvent(name string, payload []byte, remindTime int64) (err error, eventId *int64)

func (*Schedule) UpdateCronScheduleEvent added in v0.2.32

func (s *Schedule) UpdateCronScheduleEvent(eventId int64, c string) (err error)

func (*Schedule) UpdateOnceScheduleEvent added in v0.2.32

func (s *Schedule) UpdateOnceScheduleEvent(eventId int64, remindTime int64) (err error)

type ScheduleEvent added in v0.2.29

type ScheduleEvent struct {
	UGN        utils.UserGroupNamespace `json:"ugn"`
	RemindTime int64                    `json:"remindTime"`
	Name       string                   `json:"name"`
	Payload    []byte                   `json:"payload"`
}

type ScheduleEventHandler added in v0.2.29

type ScheduleEventHandler struct {
	Name    string
	Handler func(fs *EventFS, se *ScheduleEvent)
}

type ScheduleHandler added in v0.2.29

type ScheduleHandler struct {
	// contains filtered or unexported fields
}

func (*ScheduleHandler) Listen added in v0.2.29

func (sh *ScheduleHandler) Listen()

func (*ScheduleHandler) SetHandler added in v0.2.29

func (sh *ScheduleHandler) SetHandler(shs ...ScheduleEventHandler)

type SiyouFaasApi

type SiyouFaasApi map[string]func(iris.Context)

func (SiyouFaasApi) Delete

func (api SiyouFaasApi) Delete(uri string, f func(iris.Context))

func (SiyouFaasApi) Get

func (api SiyouFaasApi) Get(uri string, f func(iris.Context))

func (SiyouFaasApi) Post

func (api SiyouFaasApi) Post(uri string, f func(iris.Context))

func (SiyouFaasApi) Put

func (api SiyouFaasApi) Put(uri string, f func(iris.Context))

type SyyFile added in v0.3.3

type SyyFile struct {
	Fullpath string
	// contains filtered or unexported fields
}

SyyFile 四有云File,FaaS应用操作文件均使用此文件结构体,覆盖了os.File的所有方法实现

func (*SyyFile) Chdir added in v0.3.3

func (sf *SyyFile) Chdir() error

func (*SyyFile) Chmod added in v0.3.3

func (sf *SyyFile) Chmod(mode os.FileMode) error

func (*SyyFile) Chown added in v0.3.3

func (sf *SyyFile) Chown(uid, gid int) error

func (*SyyFile) Close added in v0.3.3

func (sf *SyyFile) Close() error

func (*SyyFile) Fd added in v0.3.3

func (sf *SyyFile) Fd() uintptr

func (*SyyFile) Name added in v0.3.3

func (sf *SyyFile) Name() string

func (*SyyFile) Read added in v0.3.3

func (sf *SyyFile) Read(b []byte) (n int, err error)

func (*SyyFile) ReadAt added in v0.3.3

func (sf *SyyFile) ReadAt(b []byte, off int64) (n int, err error)

func (*SyyFile) ReadDir added in v0.3.3

func (sf *SyyFile) ReadDir(n int) ([]os.DirEntry, error)

func (*SyyFile) ReadFrom added in v0.3.3

func (sf *SyyFile) ReadFrom(r io.Reader) (n int64, err error)

func (*SyyFile) Readdir added in v0.3.3

func (sf *SyyFile) Readdir(n int) ([]os.FileInfo, error)

func (*SyyFile) Readdirnames added in v0.3.3

func (sf *SyyFile) Readdirnames(n int) (names []string, err error)

func (*SyyFile) Seek added in v0.3.3

func (sf *SyyFile) Seek(offset int64, whence int) (ret int64, err error)

func (*SyyFile) SetDeadline added in v0.3.3

func (sf *SyyFile) SetDeadline(t time.Time) error

func (*SyyFile) SetReadDeadline added in v0.3.3

func (sf *SyyFile) SetReadDeadline(t time.Time) error

func (*SyyFile) SetWriteDeadline added in v0.3.3

func (sf *SyyFile) SetWriteDeadline(t time.Time) error

func (*SyyFile) Stat added in v0.3.3

func (sf *SyyFile) Stat() (os.FileInfo, error)

func (*SyyFile) Sync added in v0.3.3

func (sf *SyyFile) Sync() error

func (*SyyFile) SyscallConn added in v0.3.3

func (sf *SyyFile) SyscallConn() (syscall.RawConn, error)

func (*SyyFile) Truncate added in v0.3.3

func (sf *SyyFile) Truncate(size int64) error

func (*SyyFile) Write added in v0.3.3

func (sf *SyyFile) Write(b []byte) (n int, err error)

func (*SyyFile) WriteAt added in v0.3.3

func (sf *SyyFile) WriteAt(b []byte, off int64) (n int, err error)

func (*SyyFile) WriteString added in v0.3.3

func (sf *SyyFile) WriteString(s string) (n int, err error)

type TaskLevel added in v0.2.14

type TaskLevel int
const (
	HighLevel TaskLevel = iota + 1
	MidLevel
	LowLevel
)

Directories

Path Synopsis
pkg
dto

Jump to

Keyboard shortcuts

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