todo

package
v0.0.0-...-7dd91ee Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

TODO

build todo

Install go-spirit command before you build todo

Install go-spirit command
go get github.com/go-spirit/go-spirit
go install github.com/go-spirit/go-spirit
Build
> go-spirit build --config configs/build-todo.conf
Make sure the components are already registered
> ./todo list components
- function: github.com/go-spirit/spirit/component/function.newComponentFunc
- mns: github.com/go-spirit/spirit/component/mns.NewMNSComponent
- examples-todo: github.com/spirit-component/examples/todo.NewTodo
Run components
> cd $GOPATH/src/github.com/spirit-component/examples/todo
> mv $GOPATH/src/github.com/go-spirit/go-spirit/todo .
> ./todo run --config configs/todo.conf
Work with post api
> go-spirit build --config configs/build-postapi.conf
> ./postapi run --config configs/build-postapi.conf
todo.task.new
curl -X POST \
  http://127.0.0.1:8080/ \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'x-api: todo.task.new' \
  -d '{
	"name":"hello task"
}'
{
    "code": 0,
    "result": {
        "id": "68be59dc-a0a2-4186-a476-337c4fd593bd"
    }
}
todo.task.get
curl -X POST \
  http://127.0.0.1:8080/ \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'x-api: todo.task.get' \
  -d '{
	"id":"68be59dc-a0a2-4186-a476-337c4fd593bd"
}'
{
    "code": 0,
    "result": {
        "id": "68be59dc-a0a2-4186-a476-337c4fd593bd",
        "name": "hello task"
    }
}
work flow

combine the postapi and todo

Build
> go-spirit build --config configs/build-standalone.conf
Make sure the components are already registered
> ./todo list components
- function: github.com/go-spirit/spirit/component/function.newComponentFunc
- mns: github.com/go-spirit/spirit/component/mns.NewMNSComponent
- examples-todo: github.com/spirit-component/examples/todo.NewTodo
- post-api: github.com/spirit-component/postapi.NewPostAPI
Run components
> cd $GOPATH/src/github.com/spirit-component/examples/todo
> mv $GOPATH/src/github.com/go-spirit/go-spirit/todo .
> ./todo run --config configs/todo-standalone.conf
work flow

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTodo

func NewTodo(alias string, opts ...component.Option) (comp component.Component, err error)

Types

type Task

type Task struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

type TaskId

type TaskId struct {
	Id string `json:"id"`
}

type Todo

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

func (*Todo) Alias

func (p *Todo) Alias() string

func (*Todo) GetTask

func (p *Todo) GetTask(session mail.Session) (err error)

func (*Todo) NewTask

func (p *Todo) NewTask(session mail.Session) (err error)

func (*Todo) Route

func (p *Todo) Route(session mail.Session) worker.HandlerFunc

func (*Todo) Start

func (p *Todo) Start() error

func (*Todo) Stop

func (p *Todo) Stop() error

func (*Todo) ValidateTaskName

func (p *Todo) ValidateTaskName(session mail.Session) (err error)

Jump to

Keyboard shortcuts

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