server

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	AppName             = "nats-rest-config-proxy"
	DefaultPort         = 4567
	DefaultDataDir      = "data"
	ResourcesDir        = "resources"
	CurrentConfigDir    = "current"
	SnapshotsDir        = "snapshots"
	DefaultSnapshotName = "latest"
)

Variables

View Source
var (
	Version = ""
)

Functions

func NewLogger

func NewLogger(opts *Options) *logger

NewLogger returns a logger.

Types

type Options

type Options struct {
	// NoSignals marks whether to enable the signal handler.
	NoSignals bool

	// Debug enables debug messages.
	Debug bool

	// Trace enables trace messages.
	Trace bool

	// Host is the network to listen on.
	Host string

	// Port is the network port for the server.
	Port int

	// LogFile is the log file.
	LogFile string

	// DataDir is the directory for the data.
	DataDir string

	// NoLog discards the output of the logger.
	NoLog bool

	// NoColors disables the colors in the logger.
	NoColors bool

	// LogMaxSize is the maximum size in megabytes of the log file
	// before it ges rotated.
	LogMaxSize int64

	// LogMaxAge is the maximum number of days to retain old log files.
	LogMaxAge int64

	// LogMaxBackups is the maximum number of old log files to retain.
	LogMaxBackups int64

	// PublishScript is a path to a script for publishing
	// the configuration.
	PublishScript string

	// CaFile is the cert with the CA for TLS.
	CaFile string

	// CertFile is the TLS cert for the server.
	CertFile string

	// KeyFile is the key for TLS from the server.
	KeyFile string

	// VerifyAndMap verifies the client certificate.
	VerifyAndMap bool

	// HTTPUsers are the users that can connect to the server.
	HTTPUsers []string
}

Options for the server.

func ConfigureOptions

func ConfigureOptions(args []string) (*Options, error)

func (*Options) ProcessConfigFile

func (opts *Options) ProcessConfigFile(configFile string) error

type Server

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

Server is the NATS ACL Proxy server.

func NewServer

func NewServer(opts *Options) *Server

NewServer returns a configured server.

func (*Server) HandleAccounts added in v0.3.0

func (s *Server) HandleAccounts(w http.ResponseWriter, req *http.Request)

HandleAccounts

func (*Server) HandleGlobalJetStream added in v0.7.0

func (s *Server) HandleGlobalJetStream(w http.ResponseWriter, req *http.Request)

HandleGlobalJetStream

func (*Server) HandleHealthz

func (s *Server) HandleHealthz(w http.ResponseWriter, req *http.Request)

HandleHealthz handles healthz.

func (*Server) HandleIdent

func (s *Server) HandleIdent(w http.ResponseWriter, req *http.Request)

HandleIdent

func (*Server) HandleIdents

func (s *Server) HandleIdents(w http.ResponseWriter, req *http.Request)

HandleIdents

func (*Server) HandlePerm

func (s *Server) HandlePerm(w http.ResponseWriter, req *http.Request)

HandlePerm handles a request to create/update permissions.

func (*Server) HandlePerms

func (s *Server) HandlePerms(w http.ResponseWriter, req *http.Request)

HandlePerms

func (*Server) HandlePublish

func (s *Server) HandlePublish(w http.ResponseWriter, req *http.Request)

HandlePublish

func (*Server) HandlePublishV2 added in v0.3.0

func (s *Server) HandlePublishV2(w http.ResponseWriter, req *http.Request)

HandlePublishV2

func (*Server) HandleSnapshot

func (s *Server) HandleSnapshot(w http.ResponseWriter, req *http.Request)

HandleSnapshot

func (*Server) HandleSnapshotV2 added in v0.3.0

func (s *Server) HandleSnapshotV2(w http.ResponseWriter, req *http.Request)

HandleSnapshotV2

func (*Server) HandleValidateSnapshotV2 added in v0.3.2

func (s *Server) HandleValidateSnapshotV2(w http.ResponseWriter, req *http.Request)

HandleValidateSnapshotV2

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string) error

ListenAndServe takes the network address and port that the HTTP server should bind to and starts it.

func (*Server) PublishSnapshot added in v0.5.0

func (s *Server) PublishSnapshot(name string) error

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the server.

func (*Server) RunDataDirectoryRepair added in v0.8.0

func (s *Server) RunDataDirectoryRepair() error

RunDataDirectoryRepair fixes the data directory in case there are duplicates. This function is meant to be run in a standalone.

func (*Server) SetupSignalHandler

func (s *Server) SetupSignalHandler(ctx context.Context)

SetupSignalHandler enables handling process signals.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown stops the server.

func (*Server) TakeSnapshot added in v0.5.0

func (s *Server) TakeSnapshot(name string) error

func (*Server) VerifySnapshot added in v0.4.0

func (s *Server) VerifySnapshot() error

Jump to

Keyboard shortcuts

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