wuploader

package module
v0.0.0-...-c823ed1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: BSD-3-Clause Imports: 6 Imported by: 0

README

wuploader

wuploader is a file upload utility library for WAMP This repository uses nexus for WAMP client communication in golang.

wuploader is designed to integrate itself into the service library but should work when you use pure nexus too.


How it works

You pass an endpoint which should be a file upload to wuploader and it will register a handler providing high level abstractions for file uploads.

API Description

wuploader defines one procedure with the name given to the API with a polymorphic signature. Uploading is implemented in a transaction based model, which means that you have to start a transaction first:

endpoint('start', uploadSize) -> transactionID: uint64

When starting a transaction, the endpoint may verify the uploader and the upload size and MAY reject the upload, otherwise a valid transaction ID is returned, which has to be specified for subsequent calls. After the transaction has been started, data can be uploaded like this:

endpoint('data', transactionID, data) -> uploadPos: uint64

While uploading, the size of the data chunks may be varied, good sizes range from 32kB to 4MB, depending on the connection speed. After all data has been uploaded, the transaction has to be finished like this:

endpoint('finish', transactionID, args...) -> result: any

Finish calls the underlying handler with a consistent binary representation of the uploaded content and forwards any arguments/results to the caller/callee.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UploadChecker

type UploadChecker func(uploadSize int64, args wamp.List, kwargs, details wamp.Dict) error

UploadChecker is a callback type which is executed to verify the beginning of a transaction

type UploadHandler

type UploadHandler func(ctx context.Context, uploaded serialize.BinaryData, args wamp.List, kwargs, details wamp.Dict) *client.InvokeResult

UploadHandler is a callback type which is executed when the file upload has finished and the transaction should be executed.

type Uploader

type Uploader interface {
	Add(endpoint string, begin UploadChecker, handler UploadHandler) error
	Destroy(endpoint string) error
	Stop()
}

Uploader is the main interface, allowing the user to create and delete data upload endpoints

func NewUploader

func NewUploader(c *client.Client) (Uploader, error)

NewUploader creates a new uploader and starts monitoring tasks. Free the returned uploader after use using Uploader.Stop()

Jump to

Keyboard shortcuts

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