server

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: 12 Imported by: 2

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

This section is empty.

Types

type Completer

type Completer interface {
	// HandleAborted indicates that the operation has been aborted and completion steps
	// specific to abort should be executed
	HandleAborted(context.Context) error
	// HandleStopped indicates that the operation is still is progress but the service
	// is stopping
	HandleStopped(context.Context) error
	// HandleCompleted indicates that the operation has been successfully completed
	// and executes steps specific to this event
	HandleCompleted(context.Context) error
}

Completer describes completion outcomes

type DebugReporter

type DebugReporter interface {
	// GenerateDebugReport captures the state of the operation state for debugging
	GenerateDebugReport(ctx context.Context, path string) error
}

DebugReporter allows to capture the operation state

type Executor

type Executor interface {
	Completer
	// Execute executes an operation specified with req.
	Execute(req *installpb.ExecuteRequest, stream installpb.Agent_ExecuteServer) error
	// SetPhase sets the phase state without executing it.
	SetPhase(req *installpb.SetStateRequest) error
	// Complete manually completes the operation given with operationKey.
	Complete(ctx context.Context, operationKey ops.SiteOperationKey) error
}

Executor wraps a potentially failing operation

type Server

type Server struct {
	log.FieldLogger
	// contains filtered or unexported fields
}

Server implements the installer gRPC server. The server itself does not do any work and merely relays requests to an executor.

Executor is responsible for detecting end-of-operation condition and stopping and shutting down the server appropriately.

func New

func New() *Server

New returns a new instance of the installer server. Use Serve to make server start listening

func (*Server) Abort

func (r *Server) Abort(ctx context.Context, req *installpb.AbortRequest) (*types.Empty, error)

Abort aborts the operation and cleans up the state. Implements installpb.AgentServer

func (*Server) Complete

func (r *Server) Complete(ctx context.Context, req *installpb.CompleteRequest) (*types.Empty, error)

Complete manually completes the operation given with req. Implements installpb.AgentServer

func (*Server) Execute

Execute executes the operation specified with req. After the operation has been started, it dispatches the progress messages to the client until the progress channel is closed or client exits.

Implements installpb.AgentServer

func (*Server) GenerateDebugReport

func (r *Server) GenerateDebugReport(ctx context.Context, req *installpb.DebugReportRequest) (*types.Empty, error)

GenerateDebugReport requests that the installer generates the debug report. Implements installpb.AgentServer

func (*Server) Interrupted

func (r *Server) Interrupted(ctx context.Context) error

Interrupted executes abort handler on the executor. This cannot block or invoke blocking APIs since it might be invoked by the RPC agent during shutdown

func (*Server) ManualStop

func (r *Server) ManualStop(ctx context.Context, completed bool) error

ManualStop executes the stop handler on the executor. completed indicates whether the invocation is a result of a successfully completed operation. This cannot block or invoke blocking APIs since it might be invoked by the RPC agent during shutdown

func (*Server) Run

func (r *Server) Run(executor Executor, listener net.Listener) error

Run starts the server using the specified executor and blocks until either the executor completes or the operation is aborted. To properly stop all server internal processes, use Stop

func (*Server) SetState

func (r *Server) SetState(ctx context.Context, req *installpb.SetStateRequest) (*types.Empty, error)

SetState sets the specified phase state without executing it.

Implements installpb.AgentServer.

func (*Server) Shutdown

func (r *Server) Shutdown(ctx context.Context, req *installpb.ShutdownRequest) (*types.Empty, error)

Shutdown closes the server gracefully. Implements installpb.AgentServer

func (*Server) Stop

func (r *Server) Stop(ctx context.Context)

Stop gracefully stops the server

Jump to

Keyboard shortcuts

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