Documentation
¶
Index ¶
- Constants
- Variables
- func InitSysEventer(log hclog.Logger, c EventerConfig) error
- func NewEventerContext(ctx context.Context, eventer *Eventer) (context.Context, error)
- func NewRequestInfoContext(ctx context.Context, info *RequestInfo) (context.Context, error)
- func TestResetSystEventer(t *testing.T)
- func WriteAudit(ctx context.Context, caller Op, opt ...Option) error
- func WriteError(ctx context.Context, caller Op, e error, opt ...Option)
- func WriteObservation(ctx context.Context, caller Op, opt ...Option) error
- func WriteSysEvent(ctx context.Context, caller Op, data map[string]interface{})
- type Auth
- type DeliveryGuarantee
- type Eventer
- type EventerConfig
- type GrantsInfo
- type GrantsPair
- type Id
- type Op
- type Option
- func WithAuth(a *Auth) Option
- func WithDetails(d map[string]interface{}) Option
- func WithFlush() Option
- func WithHeader(d map[string]interface{}) Option
- func WithId(id string) Option
- func WithNow(now time.Time) Option
- func WithRequest(r *Request) Option
- func WithRequestInfo(i *RequestInfo) Option
- func WithResponse(r *Response) Option
- type Request
- type RequestInfo
- type Response
- type SinkConfig
- type SinkFormat
- type SinkType
- type TestConfig
- type Type
- type UserInfo
Constants ¶
const ( ServerName string = "server_name" // ServerName: event source server name ServerAddress string = "server_addr" // ServerAddress: event source server address )
Define a set of common keys and values to use in event payload maps. Having and using a common set will allow operators to more easily define event filters.
const ( OpField = "op" // OpField in an event. RequestInfoField = "request_info" // RequestInfoField in an event. VersionField = "version" // VersionField in an event DetailsField = "details" // Details field in an event. HeaderField = "header" // HeaderField in an event. IdField = "id" // IdField in an event. CreatedAtField = "created_at" // CreatedAtField in an event. TypeField = "type" // TypeField in an event. )
Variables ¶
Functions ¶
func InitSysEventer ¶
func InitSysEventer(log hclog.Logger, c EventerConfig) error
InitSysEventer provides a mechanism to initialize a "system wide" eventer singleton for Boundary
func NewEventerContext ¶
NewEventerContext will return a context containing a value of the provided Eventer
func NewRequestInfoContext ¶
NewRequestInfoContext will return a context containing a value for the provided RequestInfo
func TestResetSystEventer ¶
TestResetSysEventer will reset event.syseventer to an uninitialized state.
func WriteAudit ¶
WriteAudit will write an audit event. It will first check the ctx for an eventer, then try event.SysEventer() and if no eventer can be found an error is returned.
At least one and any combination of the supported options may be used: WithRequest, WithResponse, WithAuth, WithId, WithFlush and WithRequestInfo. All other options are ignored.
func WriteError ¶
WriteError will write an error event. It will first check the ctx for an eventer, then try event.SysEventer() and if no eventer can be found an hclog.Logger will be created and used.
The options WithId and WithRequestInfo are supported and all other options are ignored.
func WriteObservation ¶
WriteObservation will write an observation event. It will first check the ctx for an eventer, then try event.SysEventer() and if no eventer can be found an error is returned.
At least one and any combination of the supported options may be used: WithHeader, WithDetails, WithId, WithFlush and WithRequestInfo. All other options are ignored.
func WriteSysEvent ¶ added in v0.4.0
WriteSysEvent will write a sysevent using the eventer from event.SysEventer() if no eventer can be found an hclog.Logger will be created and used. This function should never be used when sending events while handling API requests.
Types ¶
type Auth ¶
type Auth struct { // AccessorId is a std audit field == auth_token public_id AccessorId string `json:"accessor_id"` UserInfo *UserInfo `json:"user_info,omitempty"` // boundary field GrantsInfo *GrantsInfo `json:"grants_info,omitempty"` UserEmail string `json:"email,omitempty"` UserName string `json:"name,omitempty"` }
type DeliveryGuarantee ¶
type DeliveryGuarantee string // DeliveryGuarantee defines the guarantees around delivery of an event type within config
const ( DefaultDeliveryGuarantee DeliveryGuarantee = "" // DefaultDeliveryGuarantee will be BestEffort Enforced DeliveryGuarantee = "enforced" // Enforced means that a delivery guarantee is enforced BestEffort DeliveryGuarantee = "best-effort" // BestEffort means that a best effort will be made to deliver an event )
type Eventer ¶
type Eventer struct {
// contains filtered or unexported fields
}
Eventer provides a method to send events to pipelines of sinks
func EventerFromContext ¶
EventerFromContext attempts to get the eventer value from the context provided
func NewEventer ¶
func NewEventer(log hclog.Logger, c EventerConfig, opt ...Option) (*Eventer, error)
NewEventer creates a new Eventer using the config. Supports options: WithNow
func SysEventer ¶
func SysEventer() *Eventer
SysEventer returns the "system wide" eventer for Boundary.
func (*Eventer) FlushNodes ¶
FlushNodes will flush any of the eventer's flushable nodes. This needs to be called whenever Boundary is stopping (aka shutting down).
type EventerConfig ¶
type EventerConfig struct { AuditDelivery DeliveryGuarantee // AuditDelivery specifies the delivery guarantees for audit events (enforced or best effort). ObservationDelivery DeliveryGuarantee // ObservationDelivery specifies the delivery guarantees for observation events (enforced or best effort). SysEventsDelivery DeliveryGuarantee // SysEventsDelivery specifies the delivery guarantees for system events (enforced or best effort). AuditEnabled bool // AuditEnabled specifies if audit events should be emitted. ObservationsEnabled bool // ObservationsEnabled specifies if observation events should be emitted. SysEventsEnabled bool // SysEventsEnabled specifies if sysevents should be emitted. Sinks []SinkConfig // Sinks are all the configured sinks }
EventerConfig supplies all the configuration needed to create/config an Eventer.
type GrantsInfo ¶
type GrantsInfo struct {
Grants []GrantsPair `json:"grants_pair,omitempty"`
}
type GrantsPair ¶
type Option ¶
type Option func(*options)
Option - how Options are passed as arguments.
func WithDetails ¶
WithDetails allows an optional map as details
func WithHeader ¶
WithHeader allows an optional map as a header
func WithRequestInfo ¶
func WithRequestInfo(i *RequestInfo) Option
WithRequestInfo allows an optional RequestInfo
type RequestInfo ¶
type RequestInfo struct { Id string `json:"id,omitempty"` Method string `json:"method,omitempty"` Path string `json:"path,omitempty"` PublicId string `json:"public_id,omitempty"` }
RequestInfo defines the fields captured about a Boundary request.
func RequestInfoFromContext ¶
func RequestInfoFromContext(ctx context.Context) (*RequestInfo, bool)
RequestInfoFromContext attempts to get the RequestInfo value from the context provided
func TestRequestInfo ¶
func TestRequestInfo(t *testing.T) *RequestInfo
TestRequestInfo provides a test RequestInfo
type SinkConfig ¶
type SinkConfig struct { Name string // Name defines a name for the sink. EventTypes []Type // EventTypes defines a list of event types that will be sent to the sink. See the docs for EventTypes for a list of accepted values. SinkType SinkType // SinkType defines the type of sink (StdoutSink or FileSink) Format SinkFormat // Format defines the format for the sink (JSONSinkFormat) Path string // Path defines the file path for the sink FileName string // FileName defines the file name for the sink RotateBytes int // RotateByes defines the number of bytes that should trigger rotation of a FileSink RotateDuration time.Duration // RotateDuration defines how often a FileSink should be rotated RotateMaxFiles int // RotateMaxFiles defines how may historical rotated files should be kept for a FileSink }
SinkConfig defines the configuration for a Eventer sink
type SinkFormat ¶
type SinkFormat string // SinkFormat defines the formatting for a sink in a config file stanza (json)
const (
JSONSinkFormat SinkFormat = "json" // JSONSinkFormat means the event is formatted as JSON
)
type SinkType ¶
type SinkType string // SinkType defines the type of sink in a config stanza (file, stdout)
type TestConfig ¶
type TestConfig struct { EventerConfig EventerConfig AllEvents *os.File ErrorEvents *os.File }
func TestEventerConfig ¶
func TestEventerConfig(t *testing.T, testName string, opt ...Option) TestConfig
TestEventerConfig creates a test config and registers a cleanup func for its test tmp files.
type Type ¶
type Type string
Type represents the event's type
const ( EveryType Type = "*" // EveryType represents every (all) types of events ObservationType Type = "observation" // ObservationType represents observation events AuditType Type = "audit" // AuditType represents audit events ErrorType Type = "error" // ErrorType represents error events SystemType Type = "system" // SysType represents system events )