Documentation
¶
Index ¶
- Variables
- func AcceptFile(q *SaveRequest) (fileID *api.TaskId, err error)
- func ChangeTaskState(pProvidedState *api.State) error
- func CheckCommonArgs(needName, needHost bool)
- func CreateTask(taskID string) error
- func DeleteTask(taskID string) error
- func GetBucketHost() string
- func GetBucketName() string
- func GetBucketPath() string
- func GetState(taskID string) (r *api.State, err error)
- func GetTaskState(taskID string) (*api.State, error)
- func GetURL(taskID string, r *http.Request, isServeTLS bool, picOp *ImageOperate) (pURL *api.URL, err error)
- func Load(plugin RikkaPlugin)
- func SubLogger(prefix string) *logger.Logger
- type HandlerWithPattern
- type ImageOperate
- type RikkaPlugin
- type SaveRequest
- type URLRequest
Constants ¶
This section is empty.
Variables ¶
var ( ArgBucketName = flag.String("bname", "", "Bucket name to store image") ArgBucketHost = flag.String("bhost", "", "Bucket host") ArgBucketPath = flag.String("bpath", "", "Where the image will be save in bucket") )
Common flags for cloud plugins like qiniu and upai
Functions ¶
func AcceptFile ¶
func AcceptFile(q *SaveRequest) (fileID *api.TaskId, err error)
AcceptFile will be called when you receive a file upload request, the SaveRequest struct contains the file.
func ChangeTaskState ¶
ChangeTaskState change the state of a task. If taskID not exist, return an error.
func CheckCommonArgs ¶
func CheckCommonArgs(needName, needHost bool)
CheckCommonArgs will check if bname and bhost is set and log their value
func CreateTask ¶
CreateTask add a task to task list. If taskID already exist, return an error.
func DeleteTask ¶
DeleteTask delete a task from task list. If taskID not exist, return an error.
func GetBucketHost ¶
func GetBucketHost() string
GetBucketHost get the host of bucket where image will be stored
func GetBucketName ¶
func GetBucketName() string
GetBucketName get the name of bucket where image will be stored
func GetBucketPath ¶
func GetBucketPath() string
GetBucketPath get the save path of bucket which image will be stored to
func GetState ¶
GetState will be called when API server receive a state request. Also be called when web server receive a view request, web server decide response a finished view html or a self-renewal html based on the return state is finished state.
func GetTaskState ¶
GetTaskState get state of a task. If task not exist, return an error.
func GetURL ¶
func GetURL(taskID string, r *http.Request, isServeTLS bool, picOp *ImageOperate) (pURL *api.URL, err error)
GetURL will be called when API server receive a url request. Also be called when web server receive a view request and GetState return a finished state. web server use the return url value to render a finished view html.
Types ¶
type HandlerWithPattern ¶
type HandlerWithPattern struct { Pattern string Handler http.HandlerFunc }
HandlerWithPattern is a struct combine a http.Handler with the pattern is will server. Plugins' ExtraHandlers func return an array of this and will be added to http.handler when init plugin.
type ImageOperate ¶
ImageOperate stand for some operate of src image, not used now.
type RikkaPlugin ¶
type RikkaPlugin interface { // Init will be called when load plugin. Init() // AcceptFile will call this. SaveRequestHandle(*SaveRequest) (*api.TaskId, error) // GetState will call this. StateRequestHandle(string) (*api.State, error) // GetURL will call this. URLRequestHandle(q *URLRequest) (*api.URL, error) // Will be added into http handler list. ExtraHandlers() []HandlerWithPattern }
RikkaPlugin is plugin interface, all plugin should implement those function.
type SaveRequest ¶
SaveRequest is a request that want to 'save'(actually upload) a file. Plugins' SaveRequestHandle func should accept a point of instance and return a string as taskID
type URLRequest ¶
type URLRequest struct { HTTPRequest *http.Request TaskID string PicOp *ImageOperate IsServeTLS bool // only fs plugin use this field }
URLRequest is a request ask for photo src url of a task. Plugins' URLRequestHandle func should accept a point of instance and return a string as URL