core

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MPL-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Category_name = map[int32]string{
		0: "UNKNOWN",
		1: "ACK",
		2: "MESSAGE",
		3: "REQUEST",
		4: "RESPONSE",
	}
	Category_value = map[string]int32{
		"UNKNOWN":  0,
		"ACK":      1,
		"MESSAGE":  2,
		"REQUEST":  3,
		"RESPONSE": 4,
	}
)

Enum value maps for Category.

View Source
var File_protobuf_msgs_proto protoreflect.FileDescriptor
View Source
var RecordStackTraces bool
View Source
var (
	RuleParamRegexp = regexp.MustCompile(`([^\\])({[^}]+})`)
)

Functions

func DelParamOrHeader

func DelParamOrHeader(httpReq *http.Request, keys ...string)

DelParamOrHeader deletes all query parameters and headers that match provided keys.

func GenerateId

func GenerateId() string

func GetParamOrHeader

func GetParamOrHeader(httpReq *http.Request, keys ...string) string

GetParamOrHeader looks for query parameters and headers for the provided keys. Keys are checked in order. Query parameters take precedence over headers.

func ReadBody

func ReadBody(body io.ReadCloser, header http.Header, maxEventSize int64) ([]byte, error)

ReadBody reads the body of a HTTP request or response, ensuring maxEventSize is not exceeded, then closes the reader. If body is 'nil' then 'nil' is returned.

Types

type Category

type Category int32
const (
	Category_UNKNOWN  Category = 0
	Category_ACK      Category = 1
	Category_MESSAGE  Category = 2
	Category_REQUEST  Category = 3
	Category_RESPONSE Category = 4
)

func (Category) Descriptor

func (Category) Descriptor() protoreflect.EnumDescriptor

func (Category) Enum

func (x Category) Enum() *Category

func (Category) EnumDescriptor deprecated

func (Category) EnumDescriptor() ([]byte, []int)

Deprecated: Use Category.Descriptor instead.

func (Category) Number

func (x Category) Number() protoreflect.EnumNumber

func (Category) String

func (x Category) String() string

func (Category) Type

type Code

type Code int
const (
	CodeUnexpected Code = iota

	CodeBrokerMismatch
	CodeBrokerUnavailable
	CodeComponentGone
	CodeComponentMismatch
	CodeContentTooLarge
	CodeInvalid
	CodeNotFound
	CodePortUnavailable
	CodeRouteInvalid
	CodeRouteNotFound
	CodeTimeout
	CodeUnauthorized
	CodeUnknownContentType
	CodeUnsupportedAdapter
)

type Component

type Component struct {
	Type     string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
	App      string `protobuf:"bytes,2,opt,name=app,proto3" json:"app,omitempty"`
	Name     string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
	Hash     string `protobuf:"bytes,4,opt,name=hash,proto3" json:"hash,omitempty"`
	Id       string `protobuf:"bytes,5,opt,name=id,proto3" json:"id,omitempty"`
	BrokerId string `protobuf:"bytes,6,opt,name=broker_id,json=brokerId,proto3" json:"broker_id,omitempty"`
	// contains filtered or unexported fields
}

func NewComponent

func NewComponent(typ api.ComponentType, app, name, hash string) *Component

func NewPlatformComponent

func NewPlatformComponent(typ api.ComponentType, name, hash string) *Component

func NewTargetComponent

func NewTargetComponent(typ api.ComponentType, name string) *Component

func (*Component) BrokerSubject

func (c *Component) BrokerSubject() string

func (*Component) Descriptor deprecated

func (*Component) Descriptor() ([]byte, []int)

Deprecated: Use Component.ProtoReflect.Descriptor instead.

func (*Component) Equal

func (lhs *Component) Equal(rhs *Component) bool

func (*Component) GetApp

func (x *Component) GetApp() string

func (*Component) GetBrokerId

func (x *Component) GetBrokerId() string

func (*Component) GetHash added in v0.6.0

func (x *Component) GetHash() string

func (*Component) GetId

func (x *Component) GetId() string

func (*Component) GetName

func (x *Component) GetName() string

func (*Component) GetType

func (x *Component) GetType() string

func (*Component) GroupKey

func (c *Component) GroupKey() string

func (*Component) GroupSubject

func (c *Component) GroupSubject() string

func (*Component) IsComplete

func (c *Component) IsComplete() bool

func (*Component) IsNameOnly

func (c *Component) IsNameOnly() bool

func (*Component) Key

func (c *Component) Key() string

func (*Component) ProtoMessage

func (*Component) ProtoMessage()

func (*Component) ProtoReflect

func (x *Component) ProtoReflect() protoreflect.Message

func (*Component) Reset

func (x *Component) Reset()

func (*Component) ShortHash added in v0.6.0

func (c *Component) ShortHash() string

func (*Component) String

func (x *Component) String() string

func (*Component) Subject

func (c *Component) Subject() string

type Err

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

func ErrBrokerMismatch

func ErrBrokerMismatch(cause ...error) *Err

func ErrBrokerUnavailable

func ErrBrokerUnavailable(cause ...error) *Err

func ErrComponentGone

func ErrComponentGone(cause ...error) *Err

func ErrComponentMismatch

func ErrComponentMismatch(cause ...error) *Err

func ErrContentTooLarge

func ErrContentTooLarge(cause ...error) *Err

func ErrInvalid

func ErrInvalid(cause ...error) *Err

func ErrNotFound

func ErrNotFound(cause ...error) *Err

func ErrPortUnavailable

func ErrPortUnavailable(cause ...error) *Err

func ErrRouteInvalid

func ErrRouteInvalid(cause ...error) *Err

func ErrRouteNotFound

func ErrRouteNotFound(cause ...error) *Err

func ErrTimeout

func ErrTimeout(cause ...error) *Err

func ErrUnauthorized

func ErrUnauthorized(cause ...error) *Err

func ErrUnexpected

func ErrUnexpected(cause ...error) *Err

func ErrUnknownContentType

func ErrUnknownContentType(cause ...error) *Err

func ErrUnsupportedAdapter

func ErrUnsupportedAdapter(cause ...error) *Err

func NewKubeFoxErr

func NewKubeFoxErr(msg string, code Code, grpcCode codes.Code, httpCode int, cause ...error) *Err

func (*Err) Code

func (e *Err) Code() Code

func (*Err) Error

func (e *Err) Error() string

func (*Err) Format

func (e *Err) Format(s fmt.State, verb rune)

func (*Err) GRPCCode

func (e *Err) GRPCCode() codes.Code

func (*Err) GRPCStatus

func (e *Err) GRPCStatus() *status.Status

func (*Err) HTTPCode

func (e *Err) HTTPCode() int

func (*Err) Is

func (e *Err) Is(err error) bool

func (*Err) MarshalJSON

func (e *Err) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface.

func (*Err) String

func (e *Err) String() string

func (*Err) UnmarshalJSON

func (e *Err) UnmarshalJSON(value []byte) error

UnmarshalJSON implements the json.Unmarshaller interface.

func (*Err) Unwrap

func (e *Err) Unwrap() error

type Event

type Event struct {
	Id          string       `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	ParentId    string       `protobuf:"bytes,2,opt,name=parent_id,json=parentId,proto3" json:"parent_id,omitempty"`
	TraceParent *SpanContext `protobuf:"bytes,3,opt,name=trace_parent,json=traceParent,proto3" json:"trace_parent,omitempty"`
	Type        string       `protobuf:"bytes,4,opt,name=type,proto3" json:"type,omitempty"`
	Category    Category     `protobuf:"varint,5,opt,name=category,proto3,enum=kubefox.proto.v1.Category" json:"category,omitempty"`
	// Unix time in nanosecond
	CreateTime int64 `protobuf:"varint,6,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`
	// TTL in nanosecond
	Ttl         int64                      `protobuf:"varint,7,opt,name=ttl,proto3" json:"ttl,omitempty"`
	Context     *EventContext              `protobuf:"bytes,8,opt,name=context,proto3" json:"context,omitempty"`
	Source      *Component                 `protobuf:"bytes,9,opt,name=source,proto3" json:"source,omitempty"`
	Target      *Component                 `protobuf:"bytes,10,opt,name=target,proto3" json:"target,omitempty"`
	Params      map[string]*structpb.Value `` /* 154-byte string literal not displayed */
	Values      map[string]*structpb.Value `` /* 154-byte string literal not displayed */
	ContentType string                     `protobuf:"bytes,14,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
	Content     []byte                     `protobuf:"bytes,15,opt,name=content,proto3" json:"content,omitempty"`
	// contains filtered or unexported fields
}

func CloneToReq

func CloneToReq(evt *Event, opts EventOpts) *Event

func CloneToResp

func CloneToResp(evt *Event, opts EventOpts) *Event

func NewErr

func NewErr(err error, opts EventOpts) *Event

func NewEvent

func NewEvent() *Event

func NewMsg

func NewMsg(opts EventOpts) *Event

func NewReq

func NewReq(opts EventOpts) *Event

func NewResp

func NewResp(opts EventOpts) *Event

func (*Event) AddHeader

func (evt *Event) AddHeader(key, value string)

func (*Event) Bind

func (evt *Event) Bind(v any) error

func (*Event) BindStrict

func (evt *Event) BindStrict(v any) error

func (*Event) Bytes

func (evt *Event) Bytes() []byte

func (*Event) DelHeader

func (evt *Event) DelHeader(key string)

func (*Event) DelQuery

func (evt *Event) DelQuery(key string)

func (*Event) DelValueMapKey

func (evt *Event) DelValueMapKey(valKey, key string)

func (*Event) Descriptor deprecated

func (*Event) Descriptor() ([]byte, []int)

Deprecated: Use Event.ProtoReflect.Descriptor instead.

func (*Event) Err

func (evt *Event) Err() error

func (*Event) EventType

func (evt *Event) EventType() api.EventType

func (*Event) GetCategory

func (x *Event) GetCategory() Category

func (*Event) GetContent

func (x *Event) GetContent() []byte

func (*Event) GetContentType

func (x *Event) GetContentType() string

func (*Event) GetContext

func (x *Event) GetContext() *EventContext

func (*Event) GetCreateTime

func (x *Event) GetCreateTime() int64

func (*Event) GetId

func (x *Event) GetId() string

func (*Event) GetParams

func (x *Event) GetParams() map[string]*structpb.Value

func (*Event) GetParentId

func (x *Event) GetParentId() string

func (*Event) GetSource

func (x *Event) GetSource() *Component

func (*Event) GetTarget

func (x *Event) GetTarget() *Component

func (*Event) GetTraceParent added in v0.6.0

func (x *Event) GetTraceParent() *SpanContext

func (*Event) GetTtl

func (x *Event) GetTtl() int64

func (*Event) GetType

func (x *Event) GetType() string

func (*Event) GetValues

func (x *Event) GetValues() map[string]*structpb.Value

func (*Event) HTTPRequest

func (evt *Event) HTTPRequest(ctx context.Context) (*http.Request, error)

func (*Event) HTTPResponse

func (evt *Event) HTTPResponse() *http.Response

func (*Event) HasContext

func (evt *Event) HasContext() bool

func (*Event) Header

func (evt *Event) Header(key string) string

func (*Event) HeaderAll

func (evt *Event) HeaderAll(key string) []string

func (*Event) HeaderDef

func (evt *Event) HeaderDef(key string, def string) string

func (*Event) HeaderV

func (evt *Event) HeaderV(key string) *api.Val

func (*Event) Param

func (evt *Event) Param(key string) string

func (*Event) ParamDef

func (evt *Event) ParamDef(key string, def string) string

func (*Event) ParamProto

func (evt *Event) ParamProto(key string) *structpb.Value

func (*Event) ParamV

func (evt *Event) ParamV(key string) *api.Val

func (*Event) PathSuffix added in v0.6.0

func (evt *Event) PathSuffix() string

func (*Event) ProtoMessage

func (*Event) ProtoMessage()

func (*Event) ProtoReflect

func (x *Event) ProtoReflect() protoreflect.Message

func (*Event) Query

func (evt *Event) Query(key string) string

func (*Event) QueryAll

func (evt *Event) QueryAll(key string) []string

func (*Event) QueryDef

func (evt *Event) QueryDef(key string, def string) string

func (*Event) QueryV

func (evt *Event) QueryV(key string) *api.Val

func (*Event) ReduceTTL

func (evt *Event) ReduceTTL(start time.Time) time.Duration

func (*Event) Reset

func (x *Event) Reset()

func (*Event) RewritePath added in v0.6.0

func (evt *Event) RewritePath(path string)

func (*Event) SetContext

func (evt *Event) SetContext(evtCtx *EventContext)

func (*Event) SetHTTPRequest

func (evt *Event) SetHTTPRequest(httpReq *http.Request, maxEventSize int64) error

func (*Event) SetHTTPResponse

func (evt *Event) SetHTTPResponse(httpResp *http.Response, maxEventSize int64) error

func (*Event) SetHeader

func (evt *Event) SetHeader(key, value string)

func (*Event) SetHeaderV

func (evt *Event) SetHeaderV(key string, value *api.Val)

func (*Event) SetJSON

func (evt *Event) SetJSON(v any) error

func (*Event) SetParam

func (evt *Event) SetParam(key string, val string)

func (*Event) SetParamProto

func (evt *Event) SetParamProto(key string, val *structpb.Value)

func (*Event) SetParamV

func (evt *Event) SetParamV(key string, val *api.Val)

func (*Event) SetParent

func (evt *Event) SetParent(parent *Event)

func (*Event) SetQuery

func (evt *Event) SetQuery(key, value string)

func (*Event) SetQueryV

func (evt *Event) SetQueryV(key string, value *api.Val)

func (*Event) SetRoute

func (evt *Event) SetRoute(route *Route)

func (*Event) SetStatus

func (evt *Event) SetStatus(code int)

func (*Event) SetStatusV

func (evt *Event) SetStatusV(val *api.Val)

func (*Event) SetTTL

func (evt *Event) SetTTL(t time.Duration)

func (*Event) SetURL

func (evt *Event) SetURL(u *url.URL)

func (*Event) SetValue

func (evt *Event) SetValue(key string, val string)

func (*Event) SetValueMap

func (evt *Event) SetValueMap(key string, m map[string][]string)

func (*Event) SetValueMapKey

func (evt *Event) SetValueMapKey(valKey, key, value string, overwrite bool)

func (*Event) SetValueProto

func (evt *Event) SetValueProto(key string, val *structpb.Value)

func (*Event) SetValueV

func (evt *Event) SetValueV(key string, val *api.Val)

func (*Event) SpanId

func (evt *Event) SpanId() string

func (*Event) Status

func (evt *Event) Status() int

func (*Event) StatusV

func (evt *Event) StatusV() *api.Val

func (*Event) Str

func (evt *Event) Str() string

func (*Event) String

func (x *Event) String() string

func (*Event) TTL

func (evt *Event) TTL() time.Duration

func (*Event) TraceId

func (evt *Event) TraceId() string

func (*Event) URL

func (evt *Event) URL() (*url.URL, error)

func (*Event) Value

func (evt *Event) Value(key string) string

func (*Event) ValueMap

func (evt *Event) ValueMap(key string) map[string][]string

func (*Event) ValueMapKey

func (evt *Event) ValueMapKey(valKey, key string) string

func (*Event) ValueMapKeyAll

func (evt *Event) ValueMapKeyAll(valKey, key string) []string

func (*Event) ValueProto

func (evt *Event) ValueProto(key string) *structpb.Value

func (*Event) ValueV

func (evt *Event) ValueV(key string) *api.Val

type EventContext

type EventContext struct {
	Platform           string `protobuf:"bytes,1,opt,name=platform,proto3" json:"platform,omitempty"`
	VirtualEnvironment string `protobuf:"bytes,2,opt,name=virtual_environment,json=virtualEnvironment,proto3" json:"virtual_environment,omitempty"`
	AppDeployment      string `protobuf:"bytes,3,opt,name=app_deployment,json=appDeployment,proto3" json:"app_deployment,omitempty"`
	ReleaseManifest    string `protobuf:"bytes,4,opt,name=release_manifest,json=releaseManifest,proto3" json:"release_manifest,omitempty"`
	// contains filtered or unexported fields
}

func (*EventContext) Descriptor deprecated

func (*EventContext) Descriptor() ([]byte, []int)

Deprecated: Use EventContext.ProtoReflect.Descriptor instead.

func (*EventContext) GetAppDeployment

func (x *EventContext) GetAppDeployment() string

func (*EventContext) GetPlatform

func (x *EventContext) GetPlatform() string

func (*EventContext) GetReleaseManifest

func (x *EventContext) GetReleaseManifest() string

func (*EventContext) GetVirtualEnvironment

func (x *EventContext) GetVirtualEnvironment() string

func (*EventContext) ProtoMessage

func (*EventContext) ProtoMessage()

func (*EventContext) ProtoReflect

func (x *EventContext) ProtoReflect() protoreflect.Message

func (*EventContext) Reset

func (x *EventContext) Reset()

func (*EventContext) String

func (x *EventContext) String() string

type EventOpts

type EventOpts struct {
	Type        api.EventType
	Parent      *Event
	Source      *Component
	Timeout     time.Duration
	Target      *Component
	TraceParent *SpanContext
}

type Frame

type Frame uintptr

Frame represents a program counter inside a stack frame. For historical reasons if Frame is interpreted as a uintptr its value represents the program counter + 1.

func (Frame) Format

func (f Frame) Format(s fmt.State, verb rune)

Format formats the frame according to the fmt.Formatter interface.

%s    source file
%d    source line
%n    function name
%v    equivalent to %s:%d

Format accepts flags that alter the printing of some verbs, as follows:

%+s   function name and path of source file relative to the compile time
      GOPATH separated by \n\t (<funcname>\n\t<path>)
%+v   equivalent to %+s:%d

func (Frame) MarshalText

func (f Frame) MarshalText() ([]byte, error)

MarshalText formats a stacktrace Frame as a text string. The output is the same as that of fmt.Sprintf("%+v", f), but without newlines or tabs.

type LimitedReader

type LimitedReader struct {
	R io.Reader // underlying reader
	N int64     // max bytes remaining
}

Copyright 2009 The Go Authors. All rights reserved. https://cs.opensource.google/go/go/+/refs/tags/go1.20:src/io/io.go;l=456 https://cs.opensource.google/go/go/+/refs/tags/go1.20:LICENSE

LimitedReader reads from R but limits the amount of data returned to just N bytes. Each call to Read updates N to reflect the new amount remaining. Read returns ErrContentTooLarge when N <= 0.

This is a variation of io.LimitedReader that returns a different err for exceeding limit and EOF.

func (*LimitedReader) Read

func (l *LimitedReader) Read(p []byte) (n int, err error)

type MatchedEvent

type MatchedEvent struct {
	Event   *Event                     `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"`
	RouteId int64                      `protobuf:"varint,2,opt,name=route_id,json=routeId,proto3" json:"route_id,omitempty"`
	Env     map[string]*structpb.Value `` /* 147-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*MatchedEvent) Descriptor deprecated

func (*MatchedEvent) Descriptor() ([]byte, []int)

Deprecated: Use MatchedEvent.ProtoReflect.Descriptor instead.

func (*MatchedEvent) GetEnv

func (x *MatchedEvent) GetEnv() map[string]*structpb.Value

func (*MatchedEvent) GetEvent

func (x *MatchedEvent) GetEvent() *Event

func (*MatchedEvent) GetRouteId

func (x *MatchedEvent) GetRouteId() int64

func (*MatchedEvent) ProtoMessage

func (*MatchedEvent) ProtoMessage()

func (*MatchedEvent) ProtoReflect

func (x *MatchedEvent) ProtoReflect() protoreflect.Message

func (*MatchedEvent) Reset

func (x *MatchedEvent) Reset()

func (*MatchedEvent) String

func (x *MatchedEvent) String() string

type Route

type Route struct {
	*api.EnvTemplate

	Id           int
	ResolvedRule string
	Priority     int

	Component    *Component
	EventContext *EventContext
}

func NewRoute

func NewRoute(id int, rule string) (*Route, error)

func (*Route) Resolve

func (r *Route) Resolve(data *api.Data) (err error)

type SpanContext added in v0.6.0

type SpanContext struct {
	TraceId    []byte `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"`
	SpanId     []byte `protobuf:"bytes,2,opt,name=span_id,json=spanId,proto3" json:"span_id,omitempty"`
	TraceState string `protobuf:"bytes,3,opt,name=trace_state,json=traceState,proto3" json:"trace_state,omitempty"`
	Flags      uint32 `protobuf:"fixed32,4,opt,name=flags,proto3" json:"flags,omitempty"`
	// contains filtered or unexported fields
}

func (*SpanContext) Descriptor deprecated added in v0.6.0

func (*SpanContext) Descriptor() ([]byte, []int)

Deprecated: Use SpanContext.ProtoReflect.Descriptor instead.

func (*SpanContext) GetFlags added in v0.6.0

func (x *SpanContext) GetFlags() uint32

func (*SpanContext) GetSpanId added in v0.6.0

func (x *SpanContext) GetSpanId() []byte

func (*SpanContext) GetTraceId added in v0.6.0

func (x *SpanContext) GetTraceId() []byte

func (*SpanContext) GetTraceState added in v0.6.0

func (x *SpanContext) GetTraceState() string

func (*SpanContext) ProtoMessage added in v0.6.0

func (*SpanContext) ProtoMessage()

func (*SpanContext) ProtoReflect added in v0.6.0

func (x *SpanContext) ProtoReflect() protoreflect.Message

func (*SpanContext) Reset added in v0.6.0

func (x *SpanContext) Reset()

func (*SpanContext) String added in v0.6.0

func (x *SpanContext) String() string

type Stack

type Stack []uintptr

Stack represents a Stack of program counters.

func (*Stack) Format

func (s *Stack) Format(st fmt.State, verb rune)

func (*Stack) StackTrace

func (s *Stack) StackTrace() StackTrace

type StackTrace

type StackTrace []Frame

StackTrace is stack of Frames from innermost (newest) to outermost (oldest).

func (StackTrace) Format

func (st StackTrace) Format(s fmt.State, verb rune)

Format formats the stack of Frames according to the fmt.Formatter interface.

%s	lists source files for each Frame in the stack
%v	lists the source file and line number for each Frame in the stack

Format accepts flags that alter the printing of some verbs, as follows:

%+v   Prints filename, function, and line number for each Frame in the stack.

Jump to

Keyboard shortcuts

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