restapi

package
v0.3.0-beta Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2018 License: MIT Imports: 27 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) Search

func (c *ClientWithCtx) Search(id string, query string) (chan<- []string, *errgroup.Group)

Search executes a SQL statement.

func (ClientWithCtx) SearchFuncLogs

func (c ClientWithCtx) SearchFuncLogs(id string, so SearchFuncLogParams) (<-chan types.FuncLog, *errgroup.Group)

SearchFuncLogs filters the function call log records.

func (*ClientWithCtx) SearchRaw

func (c *ClientWithCtx) SearchRaw(id string, query string) (io.ReadCloser, error)

SearchRaw execute a SQL query and returns result by CSV format.

func (ClientWithCtx) Servers

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

Servers returns Log server list.

func (ClientWithCtx) SetLogInfo

func (c ClientWithCtx) SetLogInfo(id string, new types.LogInfo) (updated types.LogInfo, err error)

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

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, tries int, fn func(info *types.LogInfo) error) (types.LogInfo, error)

UpdateLogInfo updates the log status. When update operation is conflicted, it retries N times.

fn() takes the latest LogInfo and update it. fn() MUST be re-executable because it may be called many times by the API client.

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          types.GID
	MinId        types.FuncLogID
	MaxId        types.FuncLogID
	MinTimestamp types.Time
	MaxTimestamp types.Time
	Limit        int64
	SortKey      SortKey
	SortOrder    SortOrder
	Sql          string
}

func (*SearchFuncLogParams) FromString

func (s *SearchFuncLogParams) FromString(
	gid, minId, maxId, minTs, maxTs, limit, sort, order, sql string,
) (invalidParamName string, err error)

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

func (*SortKey) Parse

func (key *SortKey) Parse(s string) error

type SortOrder

type SortOrder string

func (*SortOrder) Parse

func (o *SortOrder) Parse(order string, defaultOrder SortOrder) error

Jump to

Keyboard shortcuts

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