Documentation ¶
Overview ¶
+kubebuilder:object:generate=false
Index ¶
- Constants
- Variables
- func GetParamOrHeader(httpReq *http.Request, keys ...string) string
- func Version() string
- type Category
- type Component
- func (*Component) Descriptor() ([]byte, []int)deprecated
- func (c *Component) DirectSubject() string
- func (lhs *Component) Equal(rhs *Component) bool
- func (x *Component) GetCommit() string
- func (x *Component) GetId() string
- func (x *Component) GetName() string
- func (c *Component) GroupKey() string
- func (c *Component) GroupSubject() string
- func (c *Component) IsEmpty() bool
- func (c *Component) IsFull() bool
- func (c *Component) Key() string
- func (*Component) ProtoMessage()
- func (x *Component) ProtoReflect() protoreflect.Message
- func (x *Component) Reset()
- func (c *Component) ShortCommit() string
- func (x *Component) String() string
- func (c *Component) Subject() string
- type ComponentReg
- type Event
- func (evt *Event) AddHeader(key, value string) EventWriter
- func (evt *Event) Bind(v any) error
- func (evt *Event) BindStrict(v any) error
- func (evt *Event) Bytes() []byte
- func (evt *Event) DelHeader(key string) EventWriter
- func (evt *Event) DelQuery(key string) EventWriter
- func (evt *Event) DelValueMapKey(valKey, key string)
- func (*Event) Descriptor() ([]byte, []int)deprecated
- func (evt *Event) EventType() EventType
- func (x *Event) GetCategory() Category
- func (x *Event) GetContent() []byte
- func (x *Event) GetContentType() string
- func (x *Event) GetContext() *EventContext
- func (x *Event) GetCreateTime() int64
- func (x *Event) GetId() string
- func (x *Event) GetParams() map[string]*structpb.Value
- func (x *Event) GetParentId() string
- func (x *Event) GetSource() *Component
- func (x *Event) GetTarget() *Component
- func (x *Event) GetTtl() int64
- func (x *Event) GetType() string
- func (x *Event) GetValues() map[string]*structpb.Value
- func (evt *Event) HTTPRequest(ctx context.Context) (*http.Request, error)
- func (evt *Event) HTTPResponse() *http.Response
- func (evt *Event) Header(key string) string
- func (evt *Event) HeaderAll(key string) []string
- func (evt *Event) HeaderDef(key string, def string) string
- func (evt *Event) HeaderV(key string) *Val
- func (evt *Event) Param(key string) string
- func (evt *Event) ParamDef(key string, def string) string
- func (evt *Event) ParamProto(key string) *structpb.Value
- func (evt *Event) ParamV(key string) *Val
- func (*Event) ProtoMessage()
- func (x *Event) ProtoReflect() protoreflect.Message
- func (evt *Event) Query(key string) string
- func (evt *Event) QueryAll(key string) []string
- func (evt *Event) QueryDef(key string, def string) string
- func (evt *Event) QueryV(key string) *Val
- func (evt *Event) ReduceTTL(start time.Time) time.Duration
- func (x *Event) Reset()
- func (evt *Event) SetContext(evtCtx *EventContext)
- func (evt *Event) SetHTTPRequest(httpReq *http.Request) error
- func (evt *Event) SetHTTPResponse(httpResp *http.Response) error
- func (evt *Event) SetHeader(key, value string) EventWriter
- func (evt *Event) SetHeaderV(key string, value *Val) EventWriter
- func (evt *Event) SetJSON(v any) error
- func (evt *Event) SetParam(key string, val string) EventWriter
- func (evt *Event) SetParamProto(key string, val *structpb.Value) EventWriter
- func (evt *Event) SetParamV(key string, val *Val) EventWriter
- func (evt *Event) SetParent(parent *Event)
- func (evt *Event) SetQuery(key, value string) EventWriter
- func (evt *Event) SetQueryV(key string, value *Val) EventWriter
- func (evt *Event) SetSpanId(val string)
- func (evt *Event) SetStatus(code int) EventWriter
- func (evt *Event) SetStatusV(val *Val) EventWriter
- func (evt *Event) SetTraceFlags(val byte)
- func (evt *Event) SetTraceId(val string)
- func (evt *Event) SetValue(key string, val string)
- func (evt *Event) SetValueMap(key string, m map[string][]string)
- func (evt *Event) SetValueMapKey(valKey, key, value string, overwrite bool)
- func (evt *Event) SetValueProto(key string, val *structpb.Value)
- func (evt *Event) SetValueV(key string, val *Val)
- func (evt *Event) SpanId() string
- func (evt *Event) Status() int
- func (evt *Event) StatusV() *Val
- func (evt *Event) Str() string
- func (x *Event) String() string
- func (evt *Event) TTL() time.Duration
- func (evt *Event) TraceFlags() byte
- func (evt *Event) TraceId() string
- func (evt *Event) Value(key string) string
- func (evt *Event) ValueMap(key string) map[string][]string
- func (evt *Event) ValueMapKey(valKey, key string) string
- func (evt *Event) ValueMapKeyAll(valKey, key string) []string
- func (evt *Event) ValueProto(key string) *structpb.Value
- func (evt *Event) ValueV(key string) *Val
- type EventContext
- func (*EventContext) Descriptor() ([]byte, []int)deprecated
- func (x *EventContext) GetDeployment() string
- func (x *EventContext) GetEnvironment() string
- func (x *EventContext) GetRelease() string
- func (ctx *EventContext) IsDeployment() bool
- func (ctx *EventContext) IsRelease() bool
- func (*EventContext) ProtoMessage()
- func (x *EventContext) ProtoReflect() protoreflect.Message
- func (x *EventContext) Reset()
- func (x *EventContext) String() string
- type EventOpts
- type EventPredicate
- type EventReader
- type EventType
- type EventWriter
- type MatchedEvent
- func (*MatchedEvent) Descriptor() ([]byte, []int)deprecated
- func (x *MatchedEvent) GetEnv() map[string]*structpb.Value
- func (x *MatchedEvent) GetEvent() *Event
- func (x *MatchedEvent) GetRouteId() int64
- func (*MatchedEvent) ProtoMessage()
- func (x *MatchedEvent) ProtoReflect() protoreflect.Message
- func (x *MatchedEvent) Reset()
- func (x *MatchedEvent) String() string
- type Route
- type Val
- func (val *Val) Any() any
- func (val *Val) ArrayFloat() []float64
- func (val *Val) ArrayInt() []int
- func (val *Val) ArrayString() []string
- func (val *Val) Bool() bool
- func (val *Val) BoolDef(def bool) bool
- func (in *Val) DeepCopy() *Val
- func (in *Val) DeepCopyInto(out *Val)
- func (val *Val) Float() float64
- func (val *Val) FloatDef(def float64) float64
- func (val *Val) Int() int
- func (val *Val) IntDef(def int) int
- func (val *Val) IsArrayNumber() bool
- func (val *Val) IsArrayString() bool
- func (val *Val) IsBool() bool
- func (val *Val) IsNil() bool
- func (val *Val) IsNumber() bool
- func (val *Val) IsString() bool
- func (val *Val) IsUnknown() bool
- func (val *Val) MarshalJSON() ([]byte, error)
- func (val *Val) Proto() *structpb.Value
- func (val *Val) String() string
- func (val *Val) StringDef(def string) string
- func (val *Val) UnmarshalJSON(value []byte) error
- type ValType
Constants ¶
const ( LabelK8sComponent string = "kubefox.xigxog.io/component" LabelK8sComponentCommit string = "kubefox.xigxog.io/component-commit" LabelK8sPlatform string = "kubefox.xigxog.io/platform" LabelOCIComponent string = "com.xigxog.kubefox.component" LabelOCICreated string = "org.opencontainers.image.created" LabelOCIRevision string = "org.opencontainers.image.revision" LabelOCISource string = "org.opencontainers.image.source" )
Labels
const ( ValKeyHeader = "header" ValKeyHost = "host" ValKeyMethod = "method" ValKeyPath = "path" ValKeyQuery = "queryParam" ValKeyStatusCode = "statusCode" ValKeyStatus = "status" ValKeyURL = "url" ValKeyTraceId = "traceId" ValKeySpanId = "spanId" ValKeyTraceFlags = "traceFlags" )
Keys for well known values.
const ( HeaderAbbrvDep = "kf-dep" HeaderAbbrvEnv = "kf-env" HeaderAbbrvEventType = "kf-type" HeaderAdapter = "kubefox-adapter" HeaderDep = "kubefox-deployment" HeaderEnv = "kubefox-environment" HeaderEventType = "kubefox-type" HeaderShortDep = "kfd" HeaderShortEnv = "kfe" HeaderShortEventType = "kft" HeaderTraceId = "kubefox-trace-id" )
Headers and query params.
const ( CharSetUTF8 = "charset=UTF-8" DataSchemaKubefox = "xigxog.proto.v1.KubeFoxData" ContentTypeHTML = "text/html" ContentTypeJSON = "application/json" ContentTypePlain = "text/plain" ContentTypeProtobuf = "application/protobuf" )
const (
CloudEventId = "ce_id"
)
const (
DefaultRouteId = -1
)
Variables ¶
var ( ComponentName string GitCommit string GitRef string )
Injected at build time
var ( RegexpCommit = regexp.MustCompile(`^[0-9a-f]{40}$`) RegexpGitRef = regexp.MustCompile(`^[a-z0-9][a-z0-9-\\.]{0,28}[a-z0-9]$`) RegexpImage = regexp.MustCompile(`^.*:[a-z0-9-]{7}$`) RegexpName = regexp.MustCompile(`^[a-z0-9][a-z0-9-]{0,28}[a-z0-9]$`) RegexpUUID = regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`) )
var ( KubeFoxHome = utils.EnvDef("KUBEFOX_HOME", path.Join("/", "tmp", "kubefox")) FileCACert = "ca.crt" FileTLSCert = "tls.crt" FileTLSKey = "tls.key" PathCACert = path.Join(KubeFoxHome, FileCACert) PathSvcAccToken = "/var/run/secrets/kubernetes.io/serviceaccount/token" PathTLSCert = path.Join(KubeFoxHome, FileTLSCert) PathTLSKey = path.Join(KubeFoxHome, FileTLSKey) )
var ( Category_name = map[int32]string{ 0: "UNKNOWN", 1: "MESSAGE", 2: "REQUEST", 3: "RESPONSE", } Category_value = map[string]int32{ "UNKNOWN": 0, "MESSAGE": 1, "REQUEST": 2, "RESPONSE": 3, } )
Enum value maps for Category.
var (
ErrUnknownContentType = errors.New("unknown content type")
)
var File_protobuf_msgs_proto protoreflect.FileDescriptor
Functions ¶
func GetParamOrHeader ¶
GetParamOrHeader looks for query parameters and headers for the provided keys. Keys are checked in order. Query parameters take precedence over headers.
Types ¶
type Category ¶
type Category int32
func (Category) Descriptor ¶
func (Category) Descriptor() protoreflect.EnumDescriptor
func (Category) EnumDescriptor
deprecated
func (Category) Number ¶
func (x Category) Number() protoreflect.EnumNumber
func (Category) Type ¶
func (Category) Type() protoreflect.EnumType
type Component ¶
type Component struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Commit string `protobuf:"bytes,2,opt,name=commit,proto3" json:"commit,omitempty"` Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` // contains filtered or unexported fields }
func (*Component) Descriptor
deprecated
func (*Component) DirectSubject ¶
DirectSubject returns the name of the JetStream subject that Events sent directly from Broker to Component should be placed so they are accessible for replay and lookup. Use of this subject is not required if Events are sent using JetStream as they will be available on that subject.
func (*Component) GroupSubject ¶
func (*Component) ProtoMessage ¶
func (*Component) ProtoMessage()
func (*Component) ProtoReflect ¶
func (x *Component) ProtoReflect() protoreflect.Message
func (*Component) ShortCommit ¶
type ComponentReg ¶
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"` Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` Category Category `protobuf:"varint,4,opt,name=category,proto3,enum=kubefox.proto.v1.Category" json:"category,omitempty"` // Unix time in µs CreateTime int64 `protobuf:"varint,5,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"` // TTL in µs Ttl int64 `protobuf:"varint,6,opt,name=ttl,proto3" json:"ttl,omitempty"` Context *EventContext `protobuf:"bytes,7,opt,name=context,proto3" json:"context,omitempty"` Source *Component `protobuf:"bytes,8,opt,name=source,proto3" json:"source,omitempty"` Target *Component `protobuf:"bytes,9,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 (*Event) AddHeader ¶
func (evt *Event) AddHeader(key, value string) EventWriter
func (*Event) BindStrict ¶
func (*Event) DelHeader ¶
func (evt *Event) DelHeader(key string) EventWriter
func (*Event) DelQuery ¶
func (evt *Event) DelQuery(key string) EventWriter
func (*Event) DelValueMapKey ¶
func (*Event) Descriptor
deprecated
func (*Event) GetCategory ¶
func (*Event) GetContent ¶
func (*Event) GetContentType ¶
func (*Event) GetContext ¶
func (x *Event) GetContext() *EventContext
func (*Event) GetCreateTime ¶
func (*Event) GetParentId ¶
func (*Event) HTTPRequest ¶
func (*Event) HTTPResponse ¶
func (*Event) ProtoMessage ¶
func (*Event) ProtoMessage()
func (*Event) ProtoReflect ¶
func (x *Event) ProtoReflect() protoreflect.Message
func (*Event) SetContext ¶
func (evt *Event) SetContext(evtCtx *EventContext)
func (*Event) SetHeader ¶
func (evt *Event) SetHeader(key, value string) EventWriter
func (*Event) SetHeaderV ¶
func (evt *Event) SetHeaderV(key string, value *Val) EventWriter
func (*Event) SetParamProto ¶
func (evt *Event) SetParamProto(key string, val *structpb.Value) EventWriter
func (*Event) SetQuery ¶
func (evt *Event) SetQuery(key, value string) EventWriter
func (*Event) SetStatus ¶
func (evt *Event) SetStatus(code int) EventWriter
func (*Event) SetStatusV ¶
func (evt *Event) SetStatusV(val *Val) EventWriter
func (*Event) SetTraceFlags ¶
func (*Event) SetTraceId ¶
func (*Event) SetValueMapKey ¶
func (*Event) TraceFlags ¶
func (*Event) ValueMapKey ¶
func (*Event) ValueMapKeyAll ¶
type EventContext ¶
type EventContext struct { Deployment string `protobuf:"bytes,1,opt,name=deployment,proto3" json:"deployment,omitempty"` Environment string `protobuf:"bytes,2,opt,name=environment,proto3" json:"environment,omitempty"` Release string `protobuf:"bytes,3,opt,name=release,proto3" json:"release,omitempty"` // contains filtered or unexported fields }
func (*EventContext) Descriptor
deprecated
func (*EventContext) Descriptor() ([]byte, []int)
Deprecated: Use EventContext.ProtoReflect.Descriptor instead.
func (*EventContext) GetDeployment ¶
func (x *EventContext) GetDeployment() string
func (*EventContext) GetEnvironment ¶
func (x *EventContext) GetEnvironment() string
func (*EventContext) GetRelease ¶
func (x *EventContext) GetRelease() string
func (*EventContext) IsDeployment ¶
func (ctx *EventContext) IsDeployment() bool
func (*EventContext) IsRelease ¶
func (ctx *EventContext) IsRelease() bool
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 EventPredicate ¶
Takes an Event and returns true or false if rule matches.
type EventReader ¶
type EventReader interface { EventType() EventType Param(key string) string ParamV(key string) *Val ParamDef(key string, def string) string Query(key string) string QueryV(key string) *Val QueryDef(key string, def string) string QueryAll(key string) []string Header(key string) string HeaderV(key string) *Val HeaderDef(key string, def string) string HeaderAll(key string) []string Status() int StatusV() *Val Bind(v any) error Str() string Bytes() []byte }
type EventType ¶
type EventType string
const ( EventTypeComponent EventType = "io.kubefox.component" EventTypeCron EventType = "io.kubefox.cron" EventTypeDapr EventType = "io.kubefox.dapr" EventTypeHTTP EventType = "io.kubefox.http" EventTypeKubernetes EventType = "io.kubefox.kubernetes" )
Component event types
const ( EventTypeAck EventType = "io.kubefox.ack" EventTypeBootstrap EventType = "io.kubefox.bootstrap" EventTypeError EventType = "io.kubefox.error" EventTypeHealth EventType = "io.kubefox.health" EventTypeMetrics EventType = "io.kubefox.metrics" EventTypeNack EventType = "io.kubefox.nack" EventTypeRegister EventType = "io.kubefox.register" EventTypeRejected EventType = "io.kubefox.rejected" EventTypeTelemetry EventType = "io.kubefox.telemetry" EventTypeUnknown EventType = "io.kubefox.unknown" )
Platform event types
type EventWriter ¶
type EventWriter interface { EventReader SetParam(key, value string) EventWriter SetParamV(key string, value *Val) EventWriter SetQuery(key, value string) EventWriter SetQueryV(key string, value *Val) EventWriter DelQuery(key string) EventWriter SetHeader(key, value string) EventWriter SetHeaderV(key string, value *Val) EventWriter AddHeader(key, value string) EventWriter DelHeader(key string) EventWriter SetStatus(code int) EventWriter SetStatusV(val *Val) EventWriter }
type MatchedEvent ¶
type MatchedEvent struct { Event *Event `protobuf:"bytes,1,opt,name=event,proto3" json:"event,omitempty"` Env map[string]*structpb.Value `` /* 147-byte string literal not displayed */ RouteId int64 `protobuf:"varint,3,opt,name=route_id,json=routeId,proto3" json:"route_id,omitempty"` // contains filtered or unexported fields }
func (*MatchedEvent) Descriptor
deprecated
func (*MatchedEvent) Descriptor() ([]byte, []int)
Deprecated: Use MatchedEvent.ProtoReflect.Descriptor instead.
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 { Id int `json:"id"` Rule string `json:"rule"` Priority int `json:"priority"` ResolvedRule string `json:"-"` Predicate EventPredicate `json:"-"` ParseErr error `json:"-"` Component *Component `json:"-"` EventContext *EventContext `json:"-"` // contains filtered or unexported fields }
type Val ¶
type Val struct { Type ValType `json:"-"` // contains filtered or unexported fields }
+kubebuilder:object:generate=true
func ValArrayFloat ¶
func ValArrayInt ¶
func ValArrayString ¶
func (*Val) ArrayFloat ¶
ArrayFloat returns the array value if type is ArrayNumber. Otherwise nil is returned.
func (*Val) ArrayInt ¶
ArrayInt returns the array value if type is ArrayNumber. Otherwise nil is returned.
func (*Val) ArrayString ¶
ArrayString returns the array value if type is ArrayString or ArrayNumber. Otherwise nil is returned.
func (*Val) Bool ¶
Bool returns the boolean value if type is Bool. If type is Number, false will be returned if value is 0, otherwise true is returned. If type is String, an attempt to parse the boolean value will be made. If parsing fails or type is Array false will be returned.
func (*Val) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Val.
func (*Val) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*Val) Float ¶
Float returns the float64 value if type is Number. If type is Bool 1 will be returned if true, otherwise 0 is returned. If type is String an attempt to parse the number will be made. If parsing fails or type is Array 0 will be returned.
func (*Val) Int ¶
Int returns the int value if type is Number. If type is Bool 1 will be returned if true, otherwise 0 is returned. If type is String an attempt to parse the number will be made. If parsing fails or type is Array 0 will be returned.
func (*Val) IsArrayNumber ¶
func (*Val) IsArrayString ¶
func (*Val) MarshalJSON ¶
MarshalJSON implements the json.Marshaller interface.
func (*Val) String ¶
String returns the string value if type is String. If type is Bool the `fmt.Sprintf("%t", bool)` of the bool value is returned. If type is Number the `fmt.Sprintf("%f", float)` of the number value is returned. If type is Array the JSON representation of the array is returned.
func (*Val) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaller interface.