Documentation ¶
Index ¶
- Constants
- Variables
- type FlyioClustering
- type FlyioHubAndSpoke
- type Option
- func WithLogging(enable bool) Option
- func WithNATSServerOptions(natsServerOpts *server.Options) Option
- func WithPlatformAdapter(ctx context.Context, enable bool, platformCfgr PlatformConfigurator) Option
- func WithSystemUser(enable bool, username, password string) Option
- func WithTimeout(t time.Duration) Option
- func WithoutInProcessClient(enable bool) Option
- type PlatformConfigurator
- type Server
Constants ¶
const ( ClusterPort int = 4244 GatewayPort int = 7244 LeafNodePort int = 7422 )
Variables ¶
var ErrEnvVarNotFound = errors.New("Platform ENV not found")
A platform specific environment variable could not be found. This should only occur if you are trying to use a platform adapter like AdapterFlyio() while not actually deploying on Flyio.
If this error does occur when still deploying on the correct platform respective to your Adapter, this may be that the platform changed their environment implementation. If so, file an issue.
var ErrPlatformImplementationChanged = errors.New("Platform implementation changed")
Should only occur when a platform changes something in their implementation. Pillow makes assumeptions that platforms tooling will not change, but if it does this error is returned.
var ErrStartupTimedOut = errors.New("embedded nats server startup timed out")
ErrStartupTimedOut indicates that the embedded nats server exceeded its startup timeout duration.
Functions ¶
This section is empty.
Types ¶
type FlyioClustering ¶
type FlyioClustering struct { // The name to be used for clustering. Appended will be `-<REGION>` where REGION is the // Flyio region this cluster is in. ClusterName string }
FlyioClustering will cluster all intra-region machines, and super cluster regions together. Note, if JetStream is enabled ALL regions must have >= 3 machines.
type FlyioHubAndSpoke ¶
type FlyioHubAndSpoke struct { // The name to be used for the primary region cluster. ClusterName string // Disable clustering in the primary region // // This should only be enabled when the primary region has 1 node and you want to enable JS. // Changing to a clustered deployment later may result in losing any data in JS. DisableClustering bool }
FlyioHubAndSpoke will cluster all machines in your primary region, and then all other regions will have their machines individually connect to your primary region cluster as leaf nodes.
Additionally, the primary region cluster will have the JS domain of `hub` and the leaf nodes will have the structure of `leaf-<REGION>-<MACHINE_ID>`
type Option ¶
type Option func(*options) error
func WithNATSServerOptions ¶
Apply your own NATs Server Options. Note, this will override any existing options, so it's recommended to place first in the list of options in Run().
func WithPlatformAdapter ¶
func WithPlatformAdapter(ctx context.Context, enable bool, platformCfgr PlatformConfigurator) Option
The supplied platformCfgr will configure your embedded nats server for a specific network topology when deployed on the corrisponding cloud platform.
For local development purposes it's recommended to disable this by checking for an environment variable, for example:
pillow.WithPlatformAdapter(context.TODO(), os.Getenv("ENV") == "prod", &pillow.FlyioClustering{ ClusterName: "pillow-cluster", })
func WithSystemUser ¶ added in v0.7.0
Duration to wait for embedded NATS to start. Defaults to 5 seconds if omitted
func WithTimeout ¶
Duration to wait for embedded NATS to start. Defaults to 5 seconds if omitted
func WithoutInProcessClient ¶ added in v0.6.0
If enabled the clients returned from *Server.NATSClient() will communicate with the embedded server over the network instead of in-process.
type PlatformConfigurator ¶
type Server ¶
type Server struct { // Reference to the underlying nats-server server.Server NATSServer *server.Server // contains filtered or unexported fields }
func Run ¶
Applies all passed options and starts the NATS server, returning a server struct and error if there was a problem starting the server.
All configuration functions start with "With". Example WithLogging(true)
func (*Server) NATSClient ¶ added in v0.6.0
Returns a new nats client.
Client will communicate in-process unless the embedded server was started with WithoutInProcessClient(true)