autopilotrpc

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 24 Imported by: 1

Documentation

Overview

Package autopilotrpc is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var File_autopilotrpc_autopilot_proto protoreflect.FileDescriptor

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by by default until UseLogger is called.

func RegisterAutopilotHandler added in v0.3.0

func RegisterAutopilotHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterAutopilotHandler registers the http handlers for service Autopilot to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterAutopilotHandlerClient added in v0.3.0

func RegisterAutopilotHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AutopilotClient) error

RegisterAutopilotHandlerClient registers the http handlers for service Autopilot to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AutopilotClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AutopilotClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "AutopilotClient" to call the correct interceptors.

func RegisterAutopilotHandlerFromEndpoint added in v0.3.0

func RegisterAutopilotHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterAutopilotHandlerFromEndpoint is same as RegisterAutopilotHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterAutopilotHandlerServer added in v0.3.0

func RegisterAutopilotHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AutopilotServer) error

RegisterAutopilotHandlerServer registers the http handlers for service Autopilot to "mux". UnaryRPC :call AutopilotServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAutopilotHandlerFromEndpoint instead.

func RegisterAutopilotServer

func RegisterAutopilotServer(s *grpc.Server, srv AutopilotServer)

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using slog.

Types

type AutopilotClient

type AutopilotClient interface {
	// Status returns whether the daemon's autopilot agent is active.
	Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error)
	// ModifyStatus is used to modify the status of the autopilot agent, like
	// enabling or disabling it.
	ModifyStatus(ctx context.Context, in *ModifyStatusRequest, opts ...grpc.CallOption) (*ModifyStatusResponse, error)
	// QueryScores queries all available autopilot heuristics, in addition to any
	// active combination of these heruristics, for the scores they would give to
	// the given nodes.
	QueryScores(ctx context.Context, in *QueryScoresRequest, opts ...grpc.CallOption) (*QueryScoresResponse, error)
	// SetScores attempts to set the scores used by the running autopilot agent,
	// if the external scoring heuristic is enabled.
	SetScores(ctx context.Context, in *SetScoresRequest, opts ...grpc.CallOption) (*SetScoresResponse, error)
}

AutopilotClient is the client API for Autopilot service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewAutopilotClient

func NewAutopilotClient(cc grpc.ClientConnInterface) AutopilotClient

type AutopilotServer

type AutopilotServer interface {
	// Status returns whether the daemon's autopilot agent is active.
	Status(context.Context, *StatusRequest) (*StatusResponse, error)
	// ModifyStatus is used to modify the status of the autopilot agent, like
	// enabling or disabling it.
	ModifyStatus(context.Context, *ModifyStatusRequest) (*ModifyStatusResponse, error)
	// QueryScores queries all available autopilot heuristics, in addition to any
	// active combination of these heruristics, for the scores they would give to
	// the given nodes.
	QueryScores(context.Context, *QueryScoresRequest) (*QueryScoresResponse, error)
	// SetScores attempts to set the scores used by the running autopilot agent,
	// if the external scoring heuristic is enabled.
	SetScores(context.Context, *SetScoresRequest) (*SetScoresResponse, error)
}

AutopilotServer is the server API for Autopilot service.

type Config

type Config struct {
	// Manager is the running autopilot manager.
	Manager *autopilot.Manager
}

Config is the primary configuration struct for the autopilot RPC server. It contains all the items required for the rpc server to carry out its duties. The fields with struct tags are meant to be parsed as normal configuration options, while if able to be populated, the latter fields MUST also be specified.

type ModifyStatusRequest

type ModifyStatusRequest struct {

	// Whether the autopilot agent should be enabled or not.
	Enable bool `protobuf:"varint,1,opt,name=enable,proto3" json:"enable,omitempty"`
	// contains filtered or unexported fields
}

func (*ModifyStatusRequest) Descriptor deprecated

func (*ModifyStatusRequest) Descriptor() ([]byte, []int)

Deprecated: Use ModifyStatusRequest.ProtoReflect.Descriptor instead.

func (*ModifyStatusRequest) GetEnable

func (x *ModifyStatusRequest) GetEnable() bool

func (*ModifyStatusRequest) ProtoMessage

func (*ModifyStatusRequest) ProtoMessage()

func (*ModifyStatusRequest) ProtoReflect added in v0.3.0

func (x *ModifyStatusRequest) ProtoReflect() protoreflect.Message

func (*ModifyStatusRequest) Reset

func (x *ModifyStatusRequest) Reset()

func (*ModifyStatusRequest) String

func (x *ModifyStatusRequest) String() string

type ModifyStatusResponse

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

func (*ModifyStatusResponse) Descriptor deprecated

func (*ModifyStatusResponse) Descriptor() ([]byte, []int)

Deprecated: Use ModifyStatusResponse.ProtoReflect.Descriptor instead.

func (*ModifyStatusResponse) ProtoMessage

func (*ModifyStatusResponse) ProtoMessage()

func (*ModifyStatusResponse) ProtoReflect added in v0.3.0

func (x *ModifyStatusResponse) ProtoReflect() protoreflect.Message

func (*ModifyStatusResponse) Reset

func (x *ModifyStatusResponse) Reset()

func (*ModifyStatusResponse) String

func (x *ModifyStatusResponse) String() string

type QueryScoresRequest added in v0.2.0

type QueryScoresRequest struct {
	Pubkeys []string `protobuf:"bytes,1,rep,name=pubkeys,proto3" json:"pubkeys,omitempty"`
	// If set, we will ignore the local channel state when calculating scores.
	IgnoreLocalState bool `protobuf:"varint,2,opt,name=ignore_local_state,json=ignoreLocalState,proto3" json:"ignore_local_state,omitempty"`
	// contains filtered or unexported fields
}

func (*QueryScoresRequest) Descriptor deprecated added in v0.2.0

func (*QueryScoresRequest) Descriptor() ([]byte, []int)

Deprecated: Use QueryScoresRequest.ProtoReflect.Descriptor instead.

func (*QueryScoresRequest) GetIgnoreLocalState added in v0.2.0

func (x *QueryScoresRequest) GetIgnoreLocalState() bool

func (*QueryScoresRequest) GetPubkeys added in v0.2.0

func (x *QueryScoresRequest) GetPubkeys() []string

func (*QueryScoresRequest) ProtoMessage added in v0.2.0

func (*QueryScoresRequest) ProtoMessage()

func (*QueryScoresRequest) ProtoReflect added in v0.3.0

func (x *QueryScoresRequest) ProtoReflect() protoreflect.Message

func (*QueryScoresRequest) Reset added in v0.2.0

func (x *QueryScoresRequest) Reset()

func (*QueryScoresRequest) String added in v0.2.0

func (x *QueryScoresRequest) String() string

type QueryScoresResponse added in v0.2.0

type QueryScoresResponse struct {
	Results []*QueryScoresResponse_HeuristicResult `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"`
	// contains filtered or unexported fields
}

func (*QueryScoresResponse) Descriptor deprecated added in v0.2.0

func (*QueryScoresResponse) Descriptor() ([]byte, []int)

Deprecated: Use QueryScoresResponse.ProtoReflect.Descriptor instead.

func (*QueryScoresResponse) GetResults added in v0.2.0

func (*QueryScoresResponse) ProtoMessage added in v0.2.0

func (*QueryScoresResponse) ProtoMessage()

func (*QueryScoresResponse) ProtoReflect added in v0.3.0

func (x *QueryScoresResponse) ProtoReflect() protoreflect.Message

func (*QueryScoresResponse) Reset added in v0.2.0

func (x *QueryScoresResponse) Reset()

func (*QueryScoresResponse) String added in v0.2.0

func (x *QueryScoresResponse) String() string

type QueryScoresResponse_HeuristicResult added in v0.2.0

type QueryScoresResponse_HeuristicResult struct {
	Heuristic string             `protobuf:"bytes,1,opt,name=heuristic,proto3" json:"heuristic,omitempty"`
	Scores    map[string]float64 `` /* 155-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*QueryScoresResponse_HeuristicResult) Descriptor deprecated added in v0.2.0

func (*QueryScoresResponse_HeuristicResult) Descriptor() ([]byte, []int)

Deprecated: Use QueryScoresResponse_HeuristicResult.ProtoReflect.Descriptor instead.

func (*QueryScoresResponse_HeuristicResult) GetHeuristic added in v0.2.0

func (x *QueryScoresResponse_HeuristicResult) GetHeuristic() string

func (*QueryScoresResponse_HeuristicResult) GetScores added in v0.2.0

func (*QueryScoresResponse_HeuristicResult) ProtoMessage added in v0.2.0

func (*QueryScoresResponse_HeuristicResult) ProtoMessage()

func (*QueryScoresResponse_HeuristicResult) ProtoReflect added in v0.3.0

func (*QueryScoresResponse_HeuristicResult) Reset added in v0.2.0

func (*QueryScoresResponse_HeuristicResult) String added in v0.2.0

type Server added in v0.3.0

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

Server is a sub-server of the main RPC server: the autopilot RPC. This sub RPC server allows external callers to access the status of the autopilot currently active within lnd, as well as configuring it at runtime.

func New added in v0.3.0

func New(cfg *Config) (*Server, lnrpc.MacaroonPerms, error)

New returns a new instance of the autopilotrpc Autopilot sub-server. We also return the set of permissions for the macaroons that we may create within this method. If the macaroons we need aren't found in the filepath, then we'll create them on start up. If we're unable to locate, or create the macaroons we need, then we'll return with an error.

func (*Server) ModifyStatus added in v0.3.0

func (s *Server) ModifyStatus(ctx context.Context,
	in *ModifyStatusRequest) (*ModifyStatusResponse, error)

ModifyStatus activates the current autopilot agent, if active.

NOTE: Part of the AutopilotServer interface.

func (*Server) Name added in v0.3.0

func (s *Server) Name() string

Name returns a unique string representation of the sub-server. This can be used to identify the sub-server and also de-duplicate them.

NOTE: This is part of the lnrpc.SubServer interface.

func (*Server) QueryScores added in v0.3.0

func (s *Server) QueryScores(ctx context.Context, in *QueryScoresRequest) (
	*QueryScoresResponse, error)

QueryScores queries all available autopilot heuristics, in addition to any active combination of these heruristics, for the scores they would give to the given nodes.

NOTE: Part of the AutopilotServer interface.

func (*Server) SetScores added in v0.3.0

func (s *Server) SetScores(ctx context.Context,
	in *SetScoresRequest) (*SetScoresResponse, error)

SetScores sets the scores of the external score heuristic, if active.

NOTE: Part of the AutopilotServer interface.

func (*Server) Start added in v0.3.0

func (s *Server) Start() error

Start launches any helper goroutines required for the Server to function.

NOTE: This is part of the lnrpc.SubServer interface.

func (*Server) Status added in v0.3.0

func (s *Server) Status(ctx context.Context,
	in *StatusRequest) (*StatusResponse, error)

Status returns the current status of the autopilot agent.

NOTE: Part of the AutopilotServer interface.

func (*Server) Stop added in v0.3.0

func (s *Server) Stop() error

Stop signals any active goroutines for a graceful closure.

NOTE: This is part of the lnrpc.SubServer interface.

type ServerShell added in v0.5.0

type ServerShell struct {
	AutopilotServer
}

ServerShell is a shell struct holding a reference to the actual sub-server. It is used to register the gRPC sub-server with the root server before we have the necessary dependencies to populate the actual sub-server.

func (*ServerShell) CreateSubServer added in v0.5.0

func (r *ServerShell) CreateSubServer(configRegistry lnrpc.SubServerConfigDispatcher) (
	lnrpc.SubServer, lnrpc.MacaroonPerms, error)

CreateSubServer populates the subserver's dependencies using the passed SubServerConfigDispatcher. This method should fully initialize the sub-server instance, making it ready for action. It returns the macaroon permissions that the sub-server wishes to pass on to the root server for all methods routed towards it.

NOTE: This is part of the lnrpc.GrpcHandler interface.

func (*ServerShell) RegisterWithRestServer added in v0.5.0

func (r *ServerShell) RegisterWithRestServer(ctx context.Context,
	mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error

RegisterWithRestServer will be called by the root REST mux to direct a sub RPC server to register itself with the main REST mux server. Until this is called, each sub-server won't be able to have requests routed towards it.

NOTE: This is part of the lnrpc.GrpcHandler interface.

func (*ServerShell) RegisterWithRootServer added in v0.5.0

func (r *ServerShell) RegisterWithRootServer(grpcServer *grpc.Server) error

RegisterWithRootServer will be called by the root gRPC server to direct a sub RPC server to register itself with the main gRPC root server. Until this is called, each sub-server won't be able to have requests routed towards it.

NOTE: This is part of the lnrpc.GrpcHandler interface.

type SetScoresRequest added in v0.2.0

type SetScoresRequest struct {

	// The name of the heuristic to provide scores to.
	Heuristic string `protobuf:"bytes,1,opt,name=heuristic,proto3" json:"heuristic,omitempty"`
	// A map from hex-encoded public keys to scores. Scores must be in the range
	// [0.0, 1.0].
	Scores map[string]float64 `` /* 155-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*SetScoresRequest) Descriptor deprecated added in v0.2.0

func (*SetScoresRequest) Descriptor() ([]byte, []int)

Deprecated: Use SetScoresRequest.ProtoReflect.Descriptor instead.

func (*SetScoresRequest) GetHeuristic added in v0.2.0

func (x *SetScoresRequest) GetHeuristic() string

func (*SetScoresRequest) GetScores added in v0.2.0

func (x *SetScoresRequest) GetScores() map[string]float64

func (*SetScoresRequest) ProtoMessage added in v0.2.0

func (*SetScoresRequest) ProtoMessage()

func (*SetScoresRequest) ProtoReflect added in v0.3.0

func (x *SetScoresRequest) ProtoReflect() protoreflect.Message

func (*SetScoresRequest) Reset added in v0.2.0

func (x *SetScoresRequest) Reset()

func (*SetScoresRequest) String added in v0.2.0

func (x *SetScoresRequest) String() string

type SetScoresResponse added in v0.2.0

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

func (*SetScoresResponse) Descriptor deprecated added in v0.2.0

func (*SetScoresResponse) Descriptor() ([]byte, []int)

Deprecated: Use SetScoresResponse.ProtoReflect.Descriptor instead.

func (*SetScoresResponse) ProtoMessage added in v0.2.0

func (*SetScoresResponse) ProtoMessage()

func (*SetScoresResponse) ProtoReflect added in v0.3.0

func (x *SetScoresResponse) ProtoReflect() protoreflect.Message

func (*SetScoresResponse) Reset added in v0.2.0

func (x *SetScoresResponse) Reset()

func (*SetScoresResponse) String added in v0.2.0

func (x *SetScoresResponse) String() string

type StatusRequest

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

func (*StatusRequest) Descriptor deprecated

func (*StatusRequest) Descriptor() ([]byte, []int)

Deprecated: Use StatusRequest.ProtoReflect.Descriptor instead.

func (*StatusRequest) ProtoMessage

func (*StatusRequest) ProtoMessage()

func (*StatusRequest) ProtoReflect added in v0.3.0

func (x *StatusRequest) ProtoReflect() protoreflect.Message

func (*StatusRequest) Reset

func (x *StatusRequest) Reset()

func (*StatusRequest) String

func (x *StatusRequest) String() string

type StatusResponse

type StatusResponse struct {

	// Indicates whether the autopilot is active or not.
	Active bool `protobuf:"varint,1,opt,name=active,proto3" json:"active,omitempty"`
	// contains filtered or unexported fields
}

func (*StatusResponse) Descriptor deprecated

func (*StatusResponse) Descriptor() ([]byte, []int)

Deprecated: Use StatusResponse.ProtoReflect.Descriptor instead.

func (*StatusResponse) GetActive

func (x *StatusResponse) GetActive() bool

func (*StatusResponse) ProtoMessage

func (*StatusResponse) ProtoMessage()

func (*StatusResponse) ProtoReflect added in v0.3.0

func (x *StatusResponse) ProtoReflect() protoreflect.Message

func (*StatusResponse) Reset

func (x *StatusResponse) Reset()

func (*StatusResponse) String

func (x *StatusResponse) String() string

type UnimplementedAutopilotServer added in v0.3.0

type UnimplementedAutopilotServer struct {
}

UnimplementedAutopilotServer can be embedded to have forward compatible implementations.

func (*UnimplementedAutopilotServer) ModifyStatus added in v0.3.0

func (*UnimplementedAutopilotServer) QueryScores added in v0.3.0

func (*UnimplementedAutopilotServer) SetScores added in v0.3.0

func (*UnimplementedAutopilotServer) Status added in v0.3.0

Jump to

Keyboard shortcuts

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