🚀Server
Server defines a new policy server with corresponding settings
New
This method creates a new Server instance. You can pass ServerOpt functions to provide optional settings when creating a new instance.
Changing Server settings
When you already have a Server instance which settings weren't changed using ServerOpt functions, you can use the following methods on the Server instance to subsequently override them.
SetAddr
The SetAddr()
method overrides the listening address on the provided Server instance.
SetPort
The SetPort()
method will override the listening port on the provided Server instance.
Starting the Server
Starting a policy server with pps is as easy as just executing one method on the Server instance. It is important though, that you provide it with a Context
and a custom type that satisfies the pps Handler interface.
Run
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.
RunWithListener
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.
Contexts
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:
Last updated