dispatcher

package
v0.0.0-...-3bfe646 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Overview

Copyright 2019 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProgressReporter

func NewProgressReporter(ctx context.Context, dispatcher EventDispatcher, title string) utils.Progress

NewProgressReporter creates a new progress reporter using the specified dispatcher disp as output sink

Types

type Event

type Event struct {
	// Progress describes the operation progress
	Progress *ops.ProgressEntry
	// Error specifies the error if any
	Error error
	// Completed indicates whether this event is terminal
	Status Status
}

Event describes the installer progress step

func (*Event) AsProgressResponse

func (r *Event) AsProgressResponse() *installpb.ProgressResponse

AsProgressResponse translates this event to proto format

func (Event) IsCompleted

func (r Event) IsCompleted() bool

IsCompleted determines if this event indicates a completed operation event

func (Event) String

func (r Event) String() string

String formats this event as text

type EventDispatcher

type EventDispatcher interface {
	// Send sends the specified event to the client
	Send(Event)
	// Close stops the dispatcher and release its resources.
	// It is an error to invoke Send after Close
	Close()
	// Chan returns the channel that receives events.
	// Close closes this channel
	Chan() <-chan *installpb.ProgressResponse
}

EventDispatcher dispatches progress events to clients

type EventWriter

type EventWriter struct {
	EventDispatcher
}

EventWriter is an event dispatcher that can be used as an output sink for progress reporter. Implements io.Writer.

func NewWriter

func NewWriter(dispatcher EventDispatcher) *EventWriter

NewWriter creates a new event writer that can be used as a progress output sink

func (*EventWriter) Write

func (r *EventWriter) Write(p []byte) (n int, err error)

Write sends p as progress event to the server. Implements io.Writer

type Status

type Status byte

Status defines the progress status

const (
	// StatusUnknown indicates an unknown progress status
	StatusUnknown Status = 0
	// StatusCompleted indicates a completed operation
	StatusCompleted Status = iota
	// StatusCompletedPending indicates a completed operation
	// but with installer still active
	StatusCompletedPending Status = iota
)

func (Status) IsCompleted

func (r Status) IsCompleted() bool

IsCompleted returns true if this status indicates completion

Directories

Path Synopsis
package buffered implements an event dispatcher with buffering semantics
package buffered implements an event dispatcher with buffering semantics
package direct implements a synchronous event dispatcher
package direct implements a synchronous event dispatcher
internal

Jump to

Keyboard shortcuts

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