eventbus

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package eventbus provides facilities for asynchronous processing of events mediated by a type-safe bus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeWatchEvent

type ChangeWatchEvent struct {
	// RawPath contains an OS specific path to the file or directory that was
	// changed. Usually extracted from the URI.
	RawPath string
	// IsDir is true if we were able to determine that the path is a directory.
	// This is not set for delete events.
	IsDir bool
	// ChangeType specifies if the file or directory was created, updated, or deleted.
	ChangeType protocol.FileChangeType
}

ChangeWatchEvent is the event that is emitted when a client notifies the language server that a directory or file was changed outside the editor.

type DiagnosticsEvent

type DiagnosticsEvent struct {
	Doc   document.Handle
	Diags hcl.Diagnostics
}

DiagnosticsEvent is an event to signal that diagnostics are available for a file.

It is emitted after parsing a file to notify the language server to publish diagnostics to the client.

type EditEvent

type EditEvent struct {
	Doc        document.Handle
	LanguageID string
}

EditEvent is an event to signal that a file in a directory has changed.

It is usually emitted when a document is changed via a language server text edit event.

type EventBus

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

EventBus is a simple event bus that allows for subscribing to and publishing events of a specific type.

It has a static list of topics. Each topic can have multiple subscribers. When an event is published to a topic, it is sent to all subscribers.

func New

func New() *EventBus

New creates an event bus.

func (*EventBus) PublishChangeWatchEvent

func (b *EventBus) PublishChangeWatchEvent(e ChangeWatchEvent)

PublishChangeWatchEvent publishes a change watch event.

func (*EventBus) PublishDiagnosticsEvent

func (b *EventBus) PublishDiagnosticsEvent(e DiagnosticsEvent)

PublishDiagnosticsEvent publishes a diagnostics event.

func (*EventBus) PublishEditEvent

func (b *EventBus) PublishEditEvent(e EditEvent)

PublishEditEvent publishes a document edit event.

func (*EventBus) PublishNoCRDSourcesEvent

func (b *EventBus) PublishNoCRDSourcesEvent(e NoCRDSourcesEvent)

PublishNoCRDSourcesEvent publishes a no CRD sources event.

func (*EventBus) PublishOpenEvent

func (b *EventBus) PublishOpenEvent(e OpenEvent)

PublishOpenEvent publishes a document open event.

func (*EventBus) SubscribeToChangeWatchEvents

func (b *EventBus) SubscribeToChangeWatchEvents(identifier string) <-chan ChangeWatchEvent

SubscribeToChangeWatchEvents adds a subscriber to process change watch events.

func (*EventBus) SubscribeToDiagnosticsEvents

func (b *EventBus) SubscribeToDiagnosticsEvents(identifier string) <-chan DiagnosticsEvent

SubscribeToDiagnosticsEvents adds a subscriber to process diagnostics events.

func (*EventBus) SubscribeToEditEvents

func (b *EventBus) SubscribeToEditEvents(identifier string) <-chan EditEvent

SubscribeToEditEvents adds a subscriber to process document edit events.

func (*EventBus) SubscribeToNoCRDSourcesEvents

func (b *EventBus) SubscribeToNoCRDSourcesEvents(identifier string) <-chan NoCRDSourcesEvent

SubscribeToNoCRDSourcesEvents adds a subscriber to process no CRD sources events.

func (*EventBus) SubscribeToOpenEvents

func (b *EventBus) SubscribeToOpenEvents(identifier string) <-chan OpenEvent

SubscribeToOpenEvents adds a subscriber to process a document open event.

type NoCRDSourcesEvent

type NoCRDSourcesEvent struct {
	Dir string // workspace directory with no CRD config
}

NoCRDSourcesEvent is an event to signal that no CRD sources were found for a workspace directory. This is used to prompt the user to configure CRD sources.

type OpenEvent

type OpenEvent struct {
	Doc        document.Handle
	LanguageID string
}

OpenEvent is an event to signal that a document is open in the editor.

It is usually emitted when a document is opened via a language server text synchronization event.

Jump to

Keyboard shortcuts

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