example

package
v0.0.0-...-303e327 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAppHandler

func NewAppHandler(cfg AppConfig) *rpc.Router

NewAppHandler returns app server handler, use rpc.DefaultRouter

func NewFileHandler

func NewFileHandler() *rpc.Router

NewFileHandler returns file server handler

func NewMetaHandler

func NewMetaHandler() *rpc.Router

NewMetaHandler returns meta server handler

Types

type AppConfig

type AppConfig struct {
	MaxFiles int `json:"max_files"`

	SimpleConfig SimpleConfig `json:"simple_config"`
	LBConfig     LBConfig     `json:"lb_config"`
}

AppConfig app configure

type ArgsDelete

type ArgsDelete struct {
	Name string // key == name
	Mode Mode   // key == mode
}

ArgsDelete args delete args in query string, the key in getter is lowercase of field name

type ArgsDownload

type ArgsDownload struct {
	Name   string `form:"name"`
	Mode   Mode   `form:"mode"`
	Offset int    `formx:"offset,omitempty" flag:"xxx"`
	Read   int    `formx:"read,omitempty" flag:"vvv"`
}

ArgsDownload args download you can define mulits tag on fields, but need to specify tag name's order in RegisterArgsParser

type ArgsExist

type ArgsExist struct {
	Name string
}

ArgsExist args exist or not

func (*ArgsExist) Parse

func (args *ArgsExist) Parse(getter rpc.ValueGetter) error

Parse implements rpc.Parser, parse args by yourself

type ArgsRead

type ArgsRead struct {
	Size int
}

ArgsRead args read

type ArgsURIOptional

type ArgsURIOptional struct {
	Require string `json:"require"`
	Option  string `json:"option,omitempty"`
}

ArgsURIOptional argument in uri with omitempty

type ArgsUpdate

type ArgsUpdate struct {
	Name string
	Desc []byte
	Meta map[string]string
}

ArgsUpdate args update args in body, you can implement rpc.Unmarshaler to unmarshal

type ArgsUpload

type ArgsUpload struct {
	Name    string      `flag:"name"`        // required
	Size    int         `flag:"size"`        // required
	Mode    Mode        `flag:"mode"`        // required
	Desc    []byte      `flag:"desc,base64"` // required, base64 urlencode string
	Nothing interface{} `flag:"-"`           // ignored
}

ArgsUpload args upload you should register the args to rpc, cos field name in tag

type ArgsWrite

type ArgsWrite struct {
	Size int `flag:"size"`
}

ArgsWrite args upload

type Client

type Client interface {
	Write(context.Context, int, io.Reader) error
	Read(context.Context, int) (io.ReadCloser, error)
}

Client read and write client

func NewFileClient

func NewFileClient(conf *SimpleConfig) Client

NewFileClient returns file client

func NewMetaClient

func NewMetaClient(conf *LBConfig, selector rpc.Selector) Client

NewMetaClient returns meta client

type FileApp

type FileApp interface {
	Upload(*rpc.Context)
	Update(*rpc.Context)
	Delete(*rpc.Context)
	Download(*rpc.Context)
	Stream(*rpc.Context)
	Exist(*rpc.Context)
	Stat(*rpc.Context)
	List(*rpc.Context)
	OptionalArgs(*rpc.Context)
}

FileApp app handlers

func NewApp

func NewApp(cfg AppConfig) FileApp

NewApp new app

type Filer

type Filer interface {
	Write(*rpc.Context)
	Read(*rpc.Context)
}

Filer file interface

func NewFile

func NewFile() Filer

NewFile new file

type LBConfig

type LBConfig struct {
	Config rpc.LbConfig `json:"rpc_lb_config"`
}

LBConfig lb client config

type Mode

type Mode uint8

Mode file mode

const (
	ModeRW Mode
	ModeW
	ModeR
	ModeNone
)

file mode

type RespStat

type RespStat struct {
	Name  string `json:"name"`
	Size  int    `json:"size"`
	Mode  Mode
	Desc  []byte `json:"desc"`
	Ctime int64
	Mtime int64
	Meta  map[string]string
}

RespStat args stat, use json tag

func (*RespStat) Marshal

func (stat *RespStat) Marshal() ([]byte, string, error)

Marshal implements rpc.Marshaler, define you own marshaler

type SimpleConfig

type SimpleConfig struct {
	Host   string     `json:"host"`
	Config rpc.Config `json:"rpc_config"`
}

SimpleConfig simple client config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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