httpserver

package
v0.0.0-...-6b231d8 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 8 more Imports: 6 Imported by: 0

Documentation

Overview

* Tencent is pleased to support the open source community by making TKEStack * available. * * Copyright (C) 2012-2019 Tencent. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the “License”); you may not use * this file except in compliance with the License. You may obtain a copy of the * License at * * https://opensource.org/licenses/Apache-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an “AS IS” BASIS, WITHOUT * WARRANTIES OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License.

* Tencent is pleased to support the open source community by making TKEStack * available. * * Copyright (C) 2012-2019 Tencent. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the “License”); you may not use * this file except in compliance with the License. You may obtain a copy of the * License at * * https://opensource.org/licenses/Apache-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an “AS IS” BASIS, WITHOUT * WARRANTIES OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License.

* Tencent is pleased to support the open source community by making TKEStack * available. * * Copyright (C) 2012-2019 Tencent. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the “License”); you may not use * this file except in compliance with the License. You may obtain a copy of the * License at * * https://opensource.org/licenses/Apache-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an “AS IS” BASIS, WITHOUT * WARRANTIES OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// StandardQueryPath is the standard API path for querying target diagnostic results
	StandardQueryPath = "/exporter/store/query"
	// StandardHistoryPath is the standard API path for querying diagnostic history
	StandardHistoryPath = "/exporter/store/history"
	// StandardRunPath is the standard API path for starting diagnose immediately
	StandardRunPath = "/coordinator/cron/run"
	// StandardStatePath is the standard API path for getting current running state and progress
	// this API only available when the coordinator type is "cron"
	StandardStatePath = "/coordinator/cron/state"
	// StandardPeriodPath is the standard path for getting or updating running period
	// this API only available when the coordinator type is "cron"
	StandardPeriodPath = "/coordinator/cron/period"
)

Variables

View Source
var Default = NewServer()

Default is the default http server

Functions

This section is empty.

Types

type FakeResponseWriter

type FakeResponseWriter struct {
	StatusCode int
	RespData   []byte
	HeaderMap  http.Header
}

FakeResponseWriter is a fake http.ResponseWriter for handler testing

func NewFakeResponseWriter

func NewFakeResponseWriter() *FakeResponseWriter

NewFakeResponseWriter return an new FakeResponseWriter

func (*FakeResponseWriter) Header

func (f *FakeResponseWriter) Header() http.Header

Header return the HeaderMap of FakeResponseWriter

func (*FakeResponseWriter) Write

func (f *FakeResponseWriter) Write(data []byte) (int, error)

Write will append response data to FakeResponseWriter.RespData

func (*FakeResponseWriter) WriteHeader

func (f *FakeResponseWriter) WriteHeader(statusCode int)

WriteHeader set the StatusCode of FakeResponseWriter

type HistoryRequest

type HistoryRequest struct {
	// Offset is the offset of target records
	// the histories will be sorted in descending chronological order
	// so, offset=1 means the second recent record
	Offset int
	// Limit is the max record number of returned records
	Limit int
}

HistoryRequest is the request for querying history records

type HistoryResponse

type HistoryResponse struct {
	*export.History
}

HistoryResponse is the response of query history records

func NewHistoryResponse

func NewHistoryResponse() *HistoryResponse

NewHistoryResponse return a HistoryResponse with default values

type QueryRequest

type QueryRequest struct {
	// ID used to specify the target report
	ID string
	// Type is the target type of diagnostic
	// if Type is not empty, only diagnostic with type "Type" will be returned
	Type string
	// Name is the target name of diagnostic
	// if Name is not empty, only diagnostic with name "Name" will be returned
	Name string
	// Level is the max HealthyLevel of target results
	// for example:
	//      Level = HealthyLevelSerious
	//      will only return results with HealthyLevel HealthyLevelSerious, and HealthyLevelFailed
	// if Level is empty ,HealthyLevelGood will be used
	Level diagnose.HealthyLevel
	// Offset is the offset value of the request result
	Offset int
	// Limit is the max line of results
	Limit int
}

QueryRequest is the request for querying one diagnostic report

type QueryResponse

type QueryResponse struct {
	*export.AllResult
}

QueryResponse is the response of querying results

func NewQueryResponse

func NewQueryResponse() *QueryResponse

NewQueryResponse create an empty QueryResponse

type Server

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

Server is a http server of kube-jarvis all plugins can register standard APIs or extended APIs

func NewServer

func NewServer() *Server

NewServer create a new Server with default values

func (*Server) HandleFunc

func (s *Server) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))

HandleFunc registered a handler for a certain path

func (*Server) Start

func (s *Server) Start(logger logger.Logger, addr string)

Start try setup a http server if any handler registered

type StateResponse

type StateResponse struct {
	State    string
	Progress *plugins.Progress
}

StateResponse is the response of querying current state

Jump to

Keyboard shortcuts

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