restapi

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2018 License: MIT Imports: 25 Imported by: 0

README

REST API specification

The API specifications defined at app.yaml. See app.yaml.

How to show specification via Swagger UI

  1. Execute the ./swagger-ui.sh on terminal. Swagger UI server will start on foreground.
  2. Open http://localhost:8080/ on web browser.
  3. Press Ctrl+C on terminal to stop the Swagger UI server.

min-idmax-id、もしくはmin-timestampmax-timestampが指定されなかった場合、全件スキャンが発生するためレスポンスが遅くなる。 可能な限りidtimestampを指定すること。

Status API

Statusは、フラットはKey/Valueの辞書と、status versionを返す。 status versionとは0から始まる整数で、statusが更新されるたびにstatus versionが加算される。

statusを更新するには、更新対象のstatus versionと更新対象のKey/ValueのペアをPOSTする。 もしstatus versionが異なっているなら、"409 Conflict"と最新のstatusとstatus versionを返し、更新には失敗する。 更新に成功した場合、"200 OK"と新しいstatus versionを返す。

Watch API

Statusの変化を通知するLong poling用のAPI。 versionとtimeoutの2つを引数に受け取る。 下記のいずれかの状態を満たしたときに、新しいStatusVersionと、statusを返す。

  • StatusVersionが変化した
  • リクエスト受付からTIMEOUT秒経過

Documentation

Index

Constants

View Source
const (
	NoSortOrder         SortOrder = ""
	AscendingSortOrder  SortOrder = "asc"
	DescendingSortOrder SortOrder = "desc"

	NoSortKey       SortKey = ""
	SortByID        SortKey = "id"
	SortByStartTime SortKey = "start-time"
	SortByEndTime   SortKey = "end-time"
)
View Source
const (
	UserAgent = "goapptrace-restapi-client"
)

Variables

View Source
var (
	ErrConflict         = errors.New("conflict")
	ErrNotFoundGoModule = errors.New("not found GoModule")
	ErrNotFoundGoFunc   = errors.New("not found GoFunc")
	ErrNotFoundGoLine   = errors.New("not found GoLine")
)

Functions

func FormatUintptr

func FormatUintptr(ptr uintptr) string

func NewRouter

func NewRouter(args RouterArgs) *mux.Router

func ParseUintptr

func ParseUintptr(s string) (uintptr, error)

Types

type APIRequestHandler

type APIRequestHandler func(w http.ResponseWriter, r *http.Request) (status int, data interface{}, err error)

type APIWorker

type APIWorker struct {
	Api        *APIv0
	Args       *RouterArgs
	Logger     *log.Logger
	BufferSize int
	Logobj     *storage.Log
	// contains filtered or unexported fields
}

APIのレスポンスの生成を支援するworker。 api.worker() メソッドから作成し APIWorker.wait() で待ち合わせをする。 パイプラインモデルの並列処理を行う。

type APIv0

type APIv0 struct {
	RouterArgs
	Logger *log.Logger
}

Goapptrace REST API v0.xのハンドラを提供する

func (APIv0) SetHandlers

func (api APIv0) SetHandlers(router *mux.Router)

type Client

type Client struct {
	BaseUrl string
	// contains filtered or unexported fields
}

Client helps calling the Goapptrace REST API client.

func (*Client) Init

func (c *Client) Init() error

Init initialize the Goapptrace REST API client.

func (Client) WithCtx

func (c Client) WithCtx(ctx context.Context) ClientWithCtx

WithCtx returns a new ClientWithCtx object with specified context.

this method MUST use value receiver.

type ClientWithCtx

type ClientWithCtx struct {
	Client
	UseCache bool
	// contains filtered or unexported fields
}

func (*ClientWithCtx) Ctx

func (c *ClientWithCtx) Ctx() context.Context

func (ClientWithCtx) GoFunc

func (c ClientWithCtx) GoFunc(logID string, pc uintptr) (f types.GoFunc, err error)

func (ClientWithCtx) GoLine

func (c ClientWithCtx) GoLine(logID string, pc uintptr) (l types.GoLine, err error)

func (ClientWithCtx) GoModule

func (c ClientWithCtx) GoModule(logID string, pc uintptr) (m types.GoModule, err error)

func (ClientWithCtx) Goroutines

func (c ClientWithCtx) Goroutines(logID string) (gl chan types.Goroutine, err error)

func (ClientWithCtx) LogInfo

func (c ClientWithCtx) LogInfo(id string) (res types.LogInfo, err error)

LogInfo returns latest log status

func (ClientWithCtx) Logs

func (c ClientWithCtx) Logs() ([]types.LogInfo, error)

Logs returns a list of log status.

func (ClientWithCtx) RemoveLog

func (c ClientWithCtx) RemoveLog(id string) error

RemoveLog removes the specified log

func (ClientWithCtx) SearchFuncLogs

func (c ClientWithCtx) SearchFuncLogs(id string, so SearchFuncLogParams) (chan types.FuncLog, error)

SearchFuncLogs filters the function call log records.

func (ClientWithCtx) Servers

func (c ClientWithCtx) Servers() ([]ServerStatus, error)

Servers returns Log server list.

func (*ClientWithCtx) Symbols

func (c *ClientWithCtx) Symbols(logID string) (s *types.Symbols, err error)

func (*ClientWithCtx) SyncSymbols

func (c *ClientWithCtx) SyncSymbols(logID string) error

SyncSymbolsはサーバからシンボルテーブルをダウンロードし、キャッシュする。 キャッシュを作っておくことで、クライアント側のみでシンボル解決が出来るようになり、高速化が出来る。

func (ClientWithCtx) UpdateLogInfo

func (c ClientWithCtx) UpdateLogInfo(id string, old types.LogInfo) (new types.LogInfo, err error)

UpdateLogInfo updates the log status. If update operation conflicts, it returns ErrConflict.

type Encoder

type Encoder interface {
	Encode(v interface{}) error
}

type FuncLogAPIWorker

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

type GenericHeap

type GenericHeap struct {
	LenFn  func() int
	LessFn func(i, j int) bool
	SwapFn func(i, j int)
	PushFn func(x interface{})
	PopFn  func() interface{}
}

メソッドの処理を置き換え可能なheap.Interfaceの実装。

func (*GenericHeap) Len

func (h *GenericHeap) Len() int

func (*GenericHeap) Less

func (h *GenericHeap) Less(i, j int) bool

func (*GenericHeap) Pop

func (h *GenericHeap) Pop() interface{}

func (*GenericHeap) Push

func (h *GenericHeap) Push(x interface{})

func (*GenericHeap) Swap

func (h *GenericHeap) Swap(i, j int)

type HttpRequestHandler

type HttpRequestHandler func(w http.ResponseWriter, r *http.Request)

type Logs

type Logs struct {
	Logs []types.LogInfo `json:"logs"`
}

type RouterArgs

type RouterArgs struct {
	Config         *config.Config
	Storage        *storage.Storage
	SimulatorStore *simulator.StateSimulatorStore
}

type SearchFuncLogParams

type SearchFuncLogParams struct {
	Gid int64
	Fid int64
	//Mid          int64
	MinId        int64
	MaxId        int64
	MinTimestamp int64
	MaxTimestamp int64
	Limit        int64
	SortKey      SortKey
	SortOrder    SortOrder
}

func (SearchFuncLogParams) ToParamMap

func (s SearchFuncLogParams) ToParamMap() map[string]string

ToParamMap converts this to url parameters map.

type ServerStatus

type ServerStatus config.LogServerConfig

type Servers

type Servers struct {
	Servers []ServerStatus `json:"servers"`
}

type SortKey

type SortKey string

type SortOrder

type SortOrder string

Jump to

Keyboard shortcuts

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