-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathoption.go
46 lines (40 loc) · 1006 Bytes
/
option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2025 The konf authors
// Use of this source code is governed by a MIT license found in the LICENSE file.
//nolint:ireturn
package pubsub
import (
"log/slog"
"google.golang.org/api/option"
"google.golang.org/api/option/internaloption"
)
// WithProject provides GCP project ID.
//
// By default, it fetches project ID from metadata server.
func WithProject(project string) Option {
return &optionFunc{
fn: func(options *options) {
options.project = project
},
}
}
// WithLogHandler provides the slog.Handler for logs from notifier.
//
// By default, it uses handler from slog.Default().
func WithLogHandler(handler slog.Handler) Option {
return &optionFunc{
fn: func(options *options) {
if handler != nil {
options.logger = slog.New(handler)
}
},
}
}
type (
// Option configures the Notifier with specific options.
Option = option.ClientOption
optionFunc struct {
internaloption.EmbeddableAdapter
fn func(options *options)
}
options Notifier
)