dispatcher

package
v0.0.0-...-5e74752 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SHA-1 Validation
	ShaLength = 8
)

Variables

View Source
var (
	ErrValidation = errors.New("validation error")
)

Functions

func Decrypt

func Decrypt(content string, orig []byte) (string, error)

func NakedEncrypt

func NakedEncrypt(content string, orig []byte) (string, error)

Types

type Subtask

type Subtask struct {
	Handler string      `json:"handler"`
	Type    SubtaskType `json:"type"`
	Data    []string    `json:"data"`

	// Leave it empty and pass Subtask to dispatcher, and it will generate a random ID.
	ID int64 `json:"id"`
}

type SubtaskResult

type SubtaskResult struct {
	Data  []string `json:"data"`
	Error error    `json:"-"` // This member will be set by dispatcher if things go wrong.
}

type SubtaskType

type SubtaskType int
const (
	SubtaskLogin SubtaskType = iota
	SubtaskList
	SubtaskElect
)

type TaskRequest

type TaskRequest struct {
	// Handlers that accepts.
	// If multiple handlers are indicated, separate them with comma (",").
	Accepts string `json:"accepts"`

	// Base64 encoded binary cipher.
	Cipher string `json:"cipher"`
}

type TaskResponse

type TaskResponse struct {
	// Is there any new task?
	OK bool `json:"ok"`

	// Encrypted Subtask, encoded in Base64.
	Content string `json:"content"`
}

type WorkResponse

type WorkResponse struct {
	// Encrypted SubtaskResult, encoded in Base64.
	Content string `json:"content"`

	// ID of the task.
	TaskID int64 `json:"task_id"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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