Server
Server defines a new policy server with corresponding settings
Last updated
Server defines a new policy server with corresponding settings
Last updated
This method creates a new instance. You can pass functions to provide optional settings when creating a new instance.
When you already have a instance which settings weren't changed using functions, you can use the following methods on the instance to subsequently override them.
The SetAddr()
method overrides the listening address on the provided instance.
The SetPort()
method will override the listening port on the provided instance.
Starting a policy server with pps is as easy as just executing one method on the instance. It is important though, that you provide it with a Context
and a custom type that satisfies the pps interface.
Once you have a Server instance ready, all you need is to execute the Run method on it, to start a TCP policy server that is listening on the address/port combination, that you configured in it (Default: 0.0.0.0:10005
). The Run()
method returns an error in case it wasn't able to start.
If you prefer to run your policy service on a different type of listener (i. e. UNIX socket), you can do so by making use of the RunWithListener()
method. It works similar to the Run()
method, except that you'll have to provide a net.Listener
as additional argument.
pps allows you to influence specific behaviour of your policy server using vaules in the Context
you provide to the Run()
or RunWithListener()
methods. The context keys that you can set are provided via the CtxKey
type of the pps package.
Currently pps supports the following keys:
Property
Type
Description
Default
CtxNoLog
bool
When you run a server, pps by default uses
Go's log
package to log some errors to
STDERR
. If you prefer to keep the execution
silent without any logging, you can set the
CtxNoLog
context value to true
before you
hand your context to the Run*()
methods.
nil