gotodoit

package module
v0.0.0-...-96c97c1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2017 License: MIT Imports: 25 Imported by: 0

README

gotodoit

Sample Go HTTP API server for GoCon JP Sprint 2017, and Fall 2018

setup for macOS using brew

if these softwares are already installed, skip this step.

brew install postgresql
brew install go
brew install python3
PostgreSQL
-- psql -U admin -d template1
CREATE database gotodoit;
CREATE USER gotodoit_root;
ALTER USER gotodoit_root WITH SUPERUSER;
-- psql -U gotodoit_root -d gotodoit
CREATE USER gotodoit_api;
CREATE USER gotodoit_api_test;
CREATE SCHEMA gotodoit_api AUTHORIZATION gotodoit_api;
Python
pipenv --python 3.6
pipenv shell
pipenv install --dev
Go
go get -u github.com/mattn/gom
gom install

Documentation

Index

Constants

View Source
const (
	QueNameHighPriority = "high"
	QueNameLowPriority  = ""
)

Priority

Variables

This section is empty.

Functions

func NewDB

func NewDB(cfg *Config) (model.DBer, error)

NewDB creates db

func NewQueClient

func NewQueClient(db *sql.DB) (*qg.Client, error)

NewQueClient create que client

func NewWorkerDB

func NewWorkerDB(config *Config) (*sql.DB, error)

NewWorkerDB create DB

func RunServer

func RunServer(cfgPath string)

RunServer run server

func StartWorker

func StartWorker(confPath string) error

StartWorker starts workers

Types

type APIApp

type APIApp struct {
	BaseApp
	DB     model.DBer
	Logger *log.Logger
}

APIApp application

func NewApp

func NewApp(cfgPath string) (*APIApp, error)

NewApp creates app

func (*APIApp) GetTodoByID

func (app *APIApp) GetTodoByID(w http.ResponseWriter, r *http.Request) (int, interface{}, error)

GetTodoByID get todo by id

func (*APIApp) GetTodos

func (app *APIApp) GetTodos(w http.ResponseWriter, r *http.Request) (int, interface{}, error)

GetTodos get todos

func (*APIApp) GetUserDetail

func (app *APIApp) GetUserDetail(
	w http.ResponseWriter, r *http.Request) (int, interface{}, error)

GetUserDetail get user

func (*APIApp) Healthcheck

func (app *APIApp) Healthcheck(
	w http.ResponseWriter, r *http.Request) (int, interface{}, error)

Healthcheck healthcheck

type AppHandler

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

AppHandler internal

func (AppHandler) ServeHTTP

func (ah AppHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serve

type AuthModel

type AuthModel struct {
	User  *model.TodoUser
	Token string
}

AuthModel auth info

type BaseApp

type BaseApp struct {
	Config     *Config
	EstcClient *estc.Client
}

BaseApp base app global values

type Config

type Config struct {
	Environment    string       `toml:"environment"`
	ServerPort     string       `toml:"server_port"`
	DBName         string       `toml:"db_name"`
	DBUser         string       `toml:"db_user"`
	DBHost         string       `toml:"db_host"`
	DBPass         string       `toml:"db_pass"`
	DBPort         uint16       `toml:"db_port"`
	DBSSLMode      string       `toml:"db_ssl_mode"`
	PasswordPepper string       `toml:"password_pepper"`
	NumWorkers     int          `toml:"num_workers"`
	EstcConfig     *estc.Config `toml:"estc"`
}

Config app global config

func NewConfig

func NewConfig(cfgPath string) (*Config, error)

NewConfig creates config

type JobApp

type JobApp struct {
	BaseApp
	Logger *log.Logger
}

JobApp job global values

func (*JobApp) Context

func (app *JobApp) Context() context.Context

Context returns context

func (*JobApp) UpdateUserInfo

func (app *JobApp) UpdateUserInfo(j *qg.Job) error

UpdateUserInfo update user info job

type UpdateUserInfoArgs

type UpdateUserInfoArgs struct {
	UserID   string
	Email    string
	Username string
	Status   string
}

UpdateUserInfoArgs update todo etc args

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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