From 7d787324a79a886692fc8f3903a4d1cd0abad94e Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 8 Nov 2024 15:31:13 +0000 Subject: [PATCH] move option functions into option.go --- option.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 option.go diff --git a/option.go b/option.go new file mode 100644 index 0000000..b7f228d --- /dev/null +++ b/option.go @@ -0,0 +1,27 @@ +package q3rcon + +import "time" + +// Option is a functional option type that allows us to configure the VbanTxt. +type Option func(*Rcon) + +// WithLoginTimeout is a functional option to set the login timeout +func WithLoginTimeout(timeout time.Duration) Option { + return func(rcon *Rcon) { + rcon.loginTimeout = timeout + } +} + +// WithDefaultTimeout is a functional option to set the default response timeout +func WithDefaultTimeout(timeout time.Duration) Option { + return func(rcon *Rcon) { + rcon.defaultTimeout = timeout + } +} + +// WithTimeouts is a functional option to set the timeouts for responses per command +func WithTimeouts(timeouts map[string]time.Duration) Option { + return func(rcon *Rcon) { + rcon.timeouts = timeouts + } +}