kettlingar

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicMetric  bool = false
	PrivateMetric bool = true
)

Variables

View Source
var KettlingarVersion string = "v0.0.1"

Functions

func MakeClient

func MakeClient(name, url string, clientPtr interface{})

MakeClient populates a struct of function fields with RPC implementations.

Types

type DataRenderer

type DataRenderer interface {
	Render(string) (string, []byte)
}

type DefaultMethods

type DefaultMethods struct{}

func (*DefaultMethods) GetDocs

func (d *DefaultMethods) GetDocs() map[string]MethodDesc

func (*DefaultMethods) PublicApiPing

func (d *DefaultMethods) PublicApiPing(ri *RequestInfo, args PingArguments) PingResponse

type DocumentedAPI

type DocumentedAPI interface {
	GetDocs() map[string]MethodDesc
}

type KettlingarService

type KettlingarService struct {
	Name    string
	Secret  string
	Url     string
	StateFn string
	Version string

	Logger *slog.Logger
	// contains filtered or unexported fields
}

func MakeService

func MakeService(name, secret string, mux *http.ServeMux, service interface{}) *KettlingarService

func (*KettlingarService) DefaultMain

func (ks *KettlingarService) DefaultMain(osArg0 string, osArgs []string)

func (*KettlingarService) ForgivingJSON

func (ks *KettlingarService) ForgivingJSON(v interface{}) []byte

func (*KettlingarService) GetApiManifest

func (ks *KettlingarService) GetApiManifest() []MethodDesc

func (*KettlingarService) MetricsCount

func (ks *KettlingarService) MetricsCount(key string, val uint64, public bool, labels MetricLabels)

func (*KettlingarService) MetricsGuage

func (ks *KettlingarService) MetricsGuage(key string, val uint64, public bool, labels MetricLabels)

func (*KettlingarService) MetricsInfo

func (ks *KettlingarService) MetricsInfo(key, val string, public bool, labels MetricLabels)

func (*KettlingarService) MetricsSample

func (ks *KettlingarService) MetricsSample(key string, val uint64, public bool, labels MetricLabels)

func (*KettlingarService) RegisterMsgpackExtensions

func (ks *KettlingarService) RegisterMsgpackExtensions()

func (*KettlingarService) RegisterService

func (ks *KettlingarService) RegisterService(service interface{}) error

type MethodDesc

type MethodDesc struct {
	Name        string            `msgpack:"name" json:"name"`
	Help        string            `msgpack:"help" json:"help"`
	Docs        string            `msgpack:"docs" json:"docs"`
	Args        map[string]string `msgpack:"args" json:"args"`
	ArgDefaults map[string]string `msgpack:"arg_defaults" json:"arg_default"`
	DefaultMime string            `msgpack:"default_mimetype" json:"default_mimetype"`
	ReturnType  reflect.Type      `msgpack:"-" json:"-"`
	Returns     string            `msgpack:"returns" json:"returns"`
	IsGenerator bool              `msgpack:"is_generator" json:"is_generator"`
	IsPublic    bool              `msgpack:"is_public" json:"is_public"`
}

type MetricHistogram

type MetricHistogram [20]uint64

type MetricLabels

type MetricLabels map[string]string

type MetricValue

type MetricValue struct {
	Count uint64
	Sum   float64 // For response times
}

type Metrics

type Metrics struct {
	Help       map[string]string
	Info       map[string]string
	Counts     map[string]uint64
	Guages     map[string]uint64
	Histograms map[string]MetricHistogram
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics() *Metrics

type MetricsMethods

type MetricsMethods struct{}

func (*MetricsMethods) GetDocs

func (d *MetricsMethods) GetDocs() map[string]MethodDesc

func (*MetricsMethods) PublicApiMetrics

func (d *MetricsMethods) PublicApiMetrics(ri *RequestInfo) MetricsResponse

type MetricsResponse

type MetricsResponse struct {
	Timestamp   time.Time `msgpack:"timestamp" json:"timestamp"`
	PubMetrics  Metrics   `msgpack:"public_metrics" json:"public_metrics"`
	PrivMetrics Metrics   `msgpack:"private_metrics" json:"private_metrics"`
}

func (*MetricsResponse) Render

func (mr *MetricsResponse) Render(mimeType string) (string, []byte)

func (*MetricsResponse) RenderOpenMetrics

func (mr *MetricsResponse) RenderOpenMetrics() []byte

type MsgpackJsonConverter

type MsgpackJsonConverter struct {
	// ExtensionNames maps extension type codes to human-readable strings.
	ExtensionNames map[int8]string
}

MsgpackJsonConverter handles the transformation of Msgpack binary streams to JSON.

func NewJsonConverter

func NewJsonConverter() *MsgpackJsonConverter

NewConverter initializes a converter with the default standard mappings.

func (*MsgpackJsonConverter) Convert

func (c *MsgpackJsonConverter) Convert(r io.Reader, w io.Writer) error

Convert reads the entire Msgpack stream from r and writes JSON to w.

type PingArguments

type PingArguments struct {
	Methods bool `default:"false"`
}

type PingResponse

type PingResponse struct {
	Timestamp time.Time    `msgpack:"timestamp" json:"timestamp"`
	Version   string       `msgpack:"version" json:"version"`
	Methods   []MethodDesc `msgpack:"methods" json:"methods"`
}

type ProgressReporter

type ProgressReporter interface {
	GetProgress() *ProgressUpdate
}

type ProgressUpdate

type ProgressUpdate struct {
	Timestamp time.Time `msgpack:"ts" json:"ts"`
	Progress  string    `msgpack:"progress" json:"progress"`
	IsError   bool      `msgpack:"error_code" json:"error_code"`
	IsBoth    bool      `msgpack:"progress_both" json:"progress_both"`
}

func (*ProgressUpdate) GetProgress

func (progress *ProgressUpdate) GetProgress() *ProgressUpdate

type RequestInfo

type RequestInfo struct {
	Timestamp time.Time
	HttpCode  int
	Service   *KettlingarService
	Method    *MethodDesc
	Request   *http.Request
	Writer    http.ResponseWriter
	IsAuthed  bool
}

type ServiceWithShutdown added in v0.0.2

type ServiceWithShutdown interface {
	ServiceShutdown(*KettlingarService) error
}

type ServiceWithStartup added in v0.0.2

type ServiceWithStartup interface {
	ServiceStartup(*KettlingarService) error
}

Jump to

Keyboard shortcuts

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