server

package
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MODEL_BUCKET = "models"
)

Variables

This section is empty.

Functions

func NewMinioClient

func NewMinioClient(conf MinioConf) (client *minio.Client, err error)

func NewPostgreSQL

func NewPostgreSQL(conf DBConf) (db *gorm.DB, err error)

Types

type Admin

type Admin struct {
	Username string
	Password string
}

type Conf

type Conf struct {
	DB               DBConf
	CROSAllowOrigins []string
	StorageDir       string
	Web              WebConf
	CreateAdmin      bool
	Admin            Admin
	Record           Record
	Minio            MinioConf
}

func LoadConf

func LoadConf() (conf Conf, err error)

LoadConf load config from env

func (*Conf) Validate

func (c *Conf) Validate() (err error)

type DBConf

type DBConf struct {
	Database     string        `yaml:"database"`
	Username     string        `yaml:"username"`
	Password     string        `yaml:"password"`
	Port         int           `yaml:"port"`
	Host         string        `yaml:"host"`
	Reset        bool          `yaml:"reset"`
	ReconnectSec time.Duration `yaml:"reconnect_sec"`
}

type MinioConf

type MinioConf struct {
	AccessKey string
	SecretKey string
	Host      string
	Port      int
	Secure    bool
}

type Record

type Record struct {
	Code string
	URL  string
}

type Server

type Server struct {
	HTTPHandler http.Handler
	Frontend    *packr.Box
	Conf        Conf
	DB          *gorm.DB
	TuShare     *tushare.TuShare
	Minio       *minio.Client
}

func New

func New(conf Conf, frontend *packr.Box) (s *Server, err error)

func (*Server) CreateAccount

func (s *Server) CreateAccount(w http.ResponseWriter, r *http.Request)

func (*Server) CreateModel

func (s *Server) CreateModel(name, version, description, fileType string,
	userID int, status proto.ModelStatus) (modelID int, err error)

func (*Server) CreateTables

func (s *Server) CreateTables(values ...interface{}) (err error)

CreateTables create all tables

func (*Server) CreateUser

func (s *Server) CreateUser(username string, password string, role m.UserRole) (err error)

func (*Server) DeleteAccount

func (s *Server) DeleteAccount(w http.ResponseWriter, r *http.Request)

func (*Server) DropTables

func (s *Server) DropTables(values ...interface{}) (err error)

DropTables drop all tables

func (*Server) FetchAccounts

func (s *Server) FetchAccounts(w http.ResponseWriter, r *http.Request)

func (*Server) FetchRecord

func (s *Server) FetchRecord(w http.ResponseWriter, r *http.Request)

func (*Server) Free

func (s *Server) Free()

func (*Server) GetSession

func (s *Server) GetSession(r *http.Request) (sess m.Session, err error)

func (*Server) Login

func (s *Server) Login(w http.ResponseWriter, r *http.Request)

func (*Server) Logout

func (s *Server) Logout(w http.ResponseWriter, r *http.Request)

func (*Server) MinioDownload added in v0.1.24

func (s *Server) MinioDownload(objName string, fp string) (err error)

func (*Server) MinioUpload

func (s *Server) MinioUpload(fp string, objName string, contentType string) (err error)

func (*Server) ResetTables

func (s *Server) ResetTables(values ...interface{}) (err error)

ResetTables drop and create tables

func (*Server) StartOrDie

func (s *Server) StartOrDie() (err error)

func (*Server) UpdateAccount

func (s *Server) UpdateAccount(w http.ResponseWriter, r *http.Request)

type SortChunks

type SortChunks []*proto.ChunkMeta

func (SortChunks) Len

func (s SortChunks) Len() int

func (SortChunks) Less

func (s SortChunks) Less(i, j int) bool

func (SortChunks) Swap

func (s SortChunks) Swap(i, j int)

type WebConf

type WebConf struct {
	Port int
	// Timeout config
	WriteTimeoutInSec time.Duration
	ReadTimeoutInSec  time.Duration
	ReadHeaderTimeout time.Duration
	IdleTimeoutInSec  time.Duration
	ShutdownWaitInSec time.Duration
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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