diff options
Diffstat (limited to 'client_config.go')
| -rw-r--r-- | client_config.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/client_config.go b/client_config.go new file mode 100644 index 0000000..99a0f2e --- /dev/null +++ b/client_config.go @@ -0,0 +1,40 @@ +// SPDX-FileCopyrightText: 2025 M. Shulhan <ms@kilabit.info> +// SPDX-License-Identifier: GPL-3.0-only + +package lilin + +import ( + "fmt" + "net/url" + "time" +) + +// ClientConfig options for client. +type ClientConfig struct { + serverURL *url.URL + + // ServerURL define the full URL of Lilin server. + ServerURL string + + // Timeout for server connection, default to 5 seconds. + Timeout time.Duration +} + +// init validate and initialize the options.` +func (cfg *ClientConfig) init() (err error) { + var logp = `init` + + if cfg.ServerURL == `` { + return fmt.Errorf(`%s: missing ServerURL`, logp) + } + + cfg.serverURL, err = url.Parse(cfg.ServerURL) + if err != nil { + return fmt.Errorf(`%s: %s`, logp, err) + } + + if cfg.Timeout == 0 { + cfg.Timeout = defTimeout + } + return nil +} |
