settings

package
v0.0.0-...-9f416b0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAnyToInterface

func ConvertAnyToInterface(anyValue *anypb.Any) (interface{}, error)

func ConvertInterfaceToAny

func ConvertInterfaceToAny(v interface{}) (*anypb.Any, error)

func FromProtoSetting

func FromProtoSetting(s *proto.Setting) settings.Setting

func ProtoTypeToSettingType

func ProtoTypeToSettingType(t proto.SettingType) settings.SettingType

func SettingTypeToProtoType

func SettingTypeToProtoType(t settings.SettingType) proto.SettingType

func ToProtoSetting

func ToProtoSetting(s settings.Setting) *proto.Setting

Types

type Client

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

func (*Client) GetSetting

func (c *Client) GetSetting(id string) (settings.Setting, error)

func (*Client) ListSettings

func (c *Client) ListSettings() map[string]settings.Setting

func (*Client) SetSetting

func (c *Client) SetSetting(id string, value any) error

func (*Client) SetSettings

func (c *Client) SetSettings(settings map[string]any) error

type Provider

type Provider interface {
	// ListSettings returns the settings store
	ListSettings() map[string]settings.Setting

	// GetSetting returns the setting by ID. This ID should be in the form of a dot separated string
	// that represents the path to the setting. For example, "appearance.theme"
	GetSetting(id string) (settings.Setting, error)

	// SetSetting sets the value of the setting by ID
	SetSetting(id string, value any) error

	// SetSettings sets multiple settings at once
	SetSettings(settings map[string]any) error
}

Provider is the interface that must be implemented by the settings provider plugin implementations on either side of the RPC.

func NewProviderWrapper

func NewProviderWrapper(base settings.Provider) Provider

NewProviderWrapper wraps the settings provider to allow for the scoped semantics of using the same setting provider for the core and for the plugins

TODO - this is a bit messy and should be refactored. It'll do for now, as we're just trying to get the plugin system working for the time being.

type SettingsPlugin

type SettingsPlugin struct {
	plugin.Plugin
	// Concrete implementation, written in Go. This is only used for plugins
	// that are written in Go.
	Impl Provider
}

This is the implementation of plugin.Plugin so we can serve/consume this.

func (*SettingsPlugin) GRPCClient

func (p *SettingsPlugin) GRPCClient(
	_ context.Context,
	_ *plugin.GRPCBroker,
	c *grpc.ClientConn,
) (interface{}, error)

func (*SettingsPlugin) GRPCServer

func (p *SettingsPlugin) GRPCServer(_ *plugin.GRPCBroker, s *grpc.Server) error

type SettingsPluginServer

type SettingsPluginServer struct {
	// This is the real implementation
	Impl Provider
}

func (*SettingsPluginServer) GetSetting

func (*SettingsPluginServer) ListSettings

func (*SettingsPluginServer) SetSetting

func (*SettingsPluginServer) SetSettings

Jump to

Keyboard shortcuts

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