vsrpc

package
v0.0.0-...-36bf68c Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 51 Imported by: 0

Documentation

Overview

Package vsrpc provides the RPC server that Visual Studio uses to interact with azd programmatically.

The RPC server is implemented using JSON-RPC 2.0 over WebSockets.

Index

Constants

View Source
const (
	DeleteModeLocal = 1 << iota
	DeleteModeAzureResources
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AspireHost

type AspireHost struct {
	Name     string
	Path     string
	Services []*Service
}

type DeleteMode

type DeleteMode uint32

type DeploymentResult

type DeploymentResult struct {
	Success      bool
	Time         time.Time
	Message      string
	DeploymentId string
}

type Environment

type Environment struct {
	Name           string
	IsCurrent      bool
	Properties     map[string]string
	Services       []*Service
	Values         map[string]string
	LastDeployment *DeploymentResult `json:",omitempty"`
	Resources      []*Resource
}

type EnvironmentInfo

type EnvironmentInfo struct {
	Name       string
	IsCurrent  bool
	DotEnvPath string
}

type Handler

type Handler func(ctx context.Context, conn jsonrpc2.Conn, reply jsonrpc2.Replier, req jsonrpc2.Request) error

Handler is the type of function that handles incoming RPC requests.

func HandlerAction0

func HandlerAction0(f func(context.Context) error) Handler

HandlerAction0 is a helper for creating a Handler from a function that takes no arguments and returns an error.

func HandlerAction1

func HandlerAction1[T1 any](f func(context.Context, T1) error) Handler

HandlerAction1 is a helper for creating a Handler from a function that takes one argument and returns an error.

func HandlerAction2

func HandlerAction2[T1 any, T2 any](f func(context.Context, T1, T2) error) Handler

HandlerAction2 is a helper for creating a Handler from a function that takes two arguments and returns an error.

func HandlerAction3

func HandlerAction3[T1 any, T2 any, T3 any](f func(context.Context, T1, T2, T3) error) Handler

HandlerAction3 is a helper for creating a Handler from a function that takes two arguments and returns an error.

func HandlerFunc0

func HandlerFunc0[TRet any](f func(context.Context) (TRet, error)) Handler

HandlerFunc0 is a helper for creating a Handler from a function that takes no arguments and returns a value and an error.

func HandlerFunc1

func HandlerFunc1[T1 any, TRet any](f func(context.Context, T1) (TRet, error)) Handler

HandlerFunc1 is a helper for creating a Handler from a function that takes one argument and returns a value and an error.

func HandlerFunc2

func HandlerFunc2[T1 any, T2 any, TRet any](f func(context.Context, T1, T2) (TRet, error)) Handler

HandlerFunc2 is a helper for creating a Handler from a function that takes two arguments and returns a value and an error.

func HandlerFunc3

func HandlerFunc3[T1 any, T2 any, T3 any, TRet any](f func(context.Context, T1, T2, T3) (TRet, error)) Handler

HandlerFunc3 is a helper for creating a Handler from a function that takes three arguments and returns a value and an error.

func HandlerFunc4

func HandlerFunc4[T1 any, T2 any, T3 any, T4 any, TRet any](f func(context.Context, T1, T2, T3, T4) (TRet, error)) Handler

HandlerFunc4 is a helper for creating a Handler from a function that takes four arguments and returns a value and an error.

type IObserver

type IObserver[T any] struct {
	// contains filtered or unexported fields
}

IObserver is treated special by our JSON-RPC implementation and plays nicely with StreamJsonRpc's ideas on how to marshal an IObserver<T> in .NET.

The way this works is that that we can send a notification back to to the server with the method `$/invokeProxy/{handle}/{onCompleted|onNext}`. When marshalled as an argument, the wire format of IObserver<T> is:

{
  "__jsonrpc_marshaled": 1,
  "handle": <some-integer>
}

func (*IObserver[T]) OnCompleted

func (o *IObserver[T]) OnCompleted(ctx context.Context) error

func (*IObserver[T]) OnNext

func (o *IObserver[T]) OnNext(ctx context.Context, value T) error

func (*IObserver[T]) UnmarshalJSON

func (o *IObserver[T]) UnmarshalJSON(data []byte) error

type InitializeServerOptions

type InitializeServerOptions struct {
	// When non nil, AuthenticationEndpoint is the endpoint to connect to for authentication. It is in the same form as
	// expected by the AZD_AUTH_ENDPOINT environment variable. Note that both AuthenticationEndpoint and AuthenticationKey
	// need to be set for external authentication to be used.
	AuthenticationEndpoint *string `json:",omitempty"`
	// When non nil, AuthenticationKey is the key to use for authenticating to the server. It is in the same form as
	// expected by the AZD_AUTH_KEY environment variable. Note that both AuthenticationEndpoint and AuthenticationKey
	// need to be set for external authentication to be used.
	AuthenticationKey *string `json:",omitempty"`
	// When non nil, AuthenticationCertificate is a base64-encoded x509 certificate used to trust and
	// secure the communications to the server. It is in the same form as the AZD_AUTH_CERT environment variable.
	AuthenticationCertificate *string `json:",omitempty"`
}

type MessageKind

type MessageKind int
const (
	Logging MessageKind = iota
	Important
)

type MessageSeverity

type MessageSeverity int
const (
	Info MessageSeverity = iota
	Warning
	Error
)

type ProgressMessage

type ProgressMessage struct {
	Message            string
	Severity           MessageSeverity
	Time               time.Time
	Kind               MessageKind
	Code               string
	AdditionalInfoLink string
}

func (ProgressMessage) WithMessage

func (m ProgressMessage) WithMessage(message string) ProgressMessage

WithMessage returns a new ProgressMessage with the given message and timestamp set to now.

type RequestContext

type RequestContext struct {
	// The active session.
	Session Session

	// The app host project path.
	HostProjectPath string
}

RequestContext provides the context for a request to the server. It identifies the active session and the azd project being operated on.

type Resource

type Resource struct {
	Name string
	Type string
	Id   string
}

type Server

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

func NewServer

func NewServer(rootContainer *ioc.NestedContainer) *Server

func (*Server) Serve

func (s *Server) Serve(l net.Listener) error

Serve calls http.Serve with the given listener and a handler that serves the VS RPC protocol.

type Service

type Service struct {
	Name       string
	IsExternal bool
	Path       string
	Endpoint   *string `json:",omitempty"`
	ResourceId *string `json:",omitempty"`
}

type Session

type Session struct {
	Id string
}

Session represents an active connection to the server. It is returned by InitializeAsync and holds an opaque connection id that the server can use to identify the client across multiple RPC calls (since our service is exposed over multiple endpoints a single client may have multiple connections to the server, and we want a way to correlate them so we can cache state across connections).

Jump to

Keyboard shortcuts

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