server

package
v0.0.0-...-f6a1209 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package server provides a Glint server implementation.

Example:

s := &server.Server{
        DataDir:          "/var/lib/glint/",
        Host:             "glintcore.net",
        Port:             "443",
        TLSCertFile:      "/etc/letsencrypt/live/glintcore.net/cert.pem",
        TLSKeyFile:       "/etc/letsencrypt/live/glintcore.net/privkey.pem",
        PostgresHost:     "localhost",
        PostgresPort:     "5432",
        PostgresUser:     "glint",
        PostgresPassword: "password_goes_here",
        PostgresDBName:   "glint",
}
err := s.ListenAndServe()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Postgres

type Postgres struct {
	// contains filtered or unexported fields
}

func (*Postgres) AddAttributes

func (pg *Postgres) AddAttributes(file_id int64, attrs []string) error

func (*Postgres) AddFile

func (pg *Postgres) AddFile(person_id int64, path string, data string) (int64, error)

func (*Postgres) AddMetadata

func (pg *Postgres) AddMetadata(personId int64, path string, attribute string,
	metadata string) error

func (*Postgres) AddPerson

func (pg *Postgres) AddPerson(username string, fullname string, email string,
	password string) error

func (*Postgres) Authenticate

func (pg *Postgres) Authenticate(username string, password string) (bool, error)

func (*Postgres) ChangePassword

func (pg *Postgres) ChangePassword(username string, password string) error

func (*Postgres) Close

func (pg *Postgres) Close() error

func (*Postgres) Connect

func (pg *Postgres) Connect(host, port, user, password, dbname string) error

func (*Postgres) CreateSchema

func (pg *Postgres) CreateSchema() error

func (*Postgres) CreateTableAttribute

func (pg *Postgres) CreateTableAttribute(tx *sql.Tx) error

func (*Postgres) CreateTableFile

func (pg *Postgres) CreateTableFile(tx *sql.Tx) error

func (*Postgres) CreateTablePerson

func (pg *Postgres) CreateTablePerson(tx *sql.Tx) error

func (*Postgres) DeleteFile

func (pg *Postgres) DeleteFile(personId int64, path string) error

func (*Postgres) LookupData

func (pg *Postgres) LookupData(person_id int64, path string) (string, error)

func (*Postgres) LookupDataList

func (pg *Postgres) LookupDataList(person_id int64) (string, error)

func (*Postgres) LookupFileId

func (pg *Postgres) LookupFileId(personId int64, path string) (int64, error)

func (*Postgres) LookupMetadata

func (pg *Postgres) LookupMetadata(personId int64, path string, attribute string) (string,
	error)

func (*Postgres) LookupPassword

func (pg *Postgres) LookupPassword(username string) (string, error)

func (*Postgres) LookupPersonId

func (pg *Postgres) LookupPersonId(username string) (int64, error)

func (*Postgres) Open

func (pg *Postgres) Open(dataSourceName string) error

func (*Postgres) Setup

func (pg *Postgres) Setup() error

type Server

type Server struct {

	// DataDir is the name of a directory for storing the data sets,
	// metadata, and internal files that will be managed by the server.
	DataDir string

	// Host is the TCP host address to listen on.
	Host string

	// Port is the TCP port to listen on.
	Port string

	// TLSCertFile is the name of a file containing a certificate for the
	// server.
	TLSCertFile string

	// TLSKeyFile is the name of a file containing the matching private key
	// for the server.
	TLSKeyFile string

	// Logger optionally specifies a logger for the server.  If nil, the
	// log package's standard logger is used.
	Logger *log.Logger

	// DisableCORS specifies whether to disable handling of CORS (Cross-origin
	// resource sharing) requests.
	DisableCORS bool

	// Debug specifies whether debugging output should be written to the log.
	Debug bool

	PostgresHost     string
	PostgresPort     string
	PostgresUser     string
	PostgresPassword string
	PostgresDBName   string

	DebugAllowInsecureCORS bool

	StaticDir string

	StorageModule string
	// contains filtered or unexported fields
}

Server defines parameters for running a Glint server.

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe() error

ListenAndServe listens on the TCP host address srv.Host and port srv.Port, and handles requests on incoming connections. ListenAndServe always returns a non-nil error; after Shutdown or Close, the returned error is http.ErrServerClosed.

type Storage

type Storage interface {
	Open(dataSourceName string) error

	Close() error

	Setup() error

	//AddMetadata()
	AddMetadata(personId int64, path string, attribute string,
		metadata string) error

	//LookupMetadata()
	LookupMetadata(personId int64, path string, attribute string) (string,
		error)

	//LookupData()
	LookupData(person_id int64, path string) (string, error)

	//LookupDataList()
	LookupDataList(person_id int64) (string, error)

	//AddFile()
	AddFile(person_id int64, path string, data string) (int64, error)

	//DeleteFile()
	DeleteFile(personId int64, path string) error

	LookupPassword(username string) (string, error)
	Authenticate(username string, password string) (bool, error)
	CreateTablePerson(tx *sql.Tx) error
	ChangePassword(username string, password string) error
	LookupPersonId(username string) (int64, error)
	AddPerson(username string, fullname string, email string,
		password string) error
	LookupFileId(personId int64, path string) (int64, error)
	AddAttributes(file_id int64, attrs []string) error
	CreateTableAttribute(tx *sql.Tx) error
	CreateTableFile(tx *sql.Tx) error
	CreateSchema() error
}

func StoragePlugin

func StoragePlugin(pluginFile string) (Storage, error)

type StorageFiles

type StorageFiles struct {
	// contains filtered or unexported fields
}

func (*StorageFiles) Close

func (fs *StorageFiles) Close() error

func (*StorageFiles) Open

func (fs *StorageFiles) Open(dataSourceName string) error

Jump to

Keyboard shortcuts

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