File: config.go

package info (click to toggle)
golang-gogottrpc 0.0~git20180205.d452837-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 252 kB
  • sloc: makefile: 2
file content (23 lines) | stat: -rw-r--r-- 557 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package ttrpc

import "github.com/pkg/errors"

type serverConfig struct {
	handshaker Handshaker
}

type ServerOpt func(*serverConfig) error

// WithServerHandshaker can be passed to NewServer to ensure that the
// handshaker is called before every connection attempt.
//
// Only one handshaker is allowed per server.
func WithServerHandshaker(handshaker Handshaker) ServerOpt {
	return func(c *serverConfig) error {
		if c.handshaker != nil {
			return errors.New("only one handshaker allowed per server")
		}
		c.handshaker = handshaker
		return nil
	}
}