Skip to content

Commit 688a844

Browse files
more package docs
1 parent 1c11b5b commit 688a844

File tree

7 files changed

+42
-8
lines changed

7 files changed

+42
-8
lines changed

pkg/randkey/randkey.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Package randkey provides utility functions to generate random uint64 keys.
2+
Package randkey provides utility functions to generate random uint64 keys in different formats.
33
*/
44
package randkey
55

pkg/redact/redact.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// Package redact contains utilities functions to obscure sensitive data.
1+
/*
2+
Package redact contains utility functions to obscure sensitive data.
3+
4+
This is useful for logging and debugging, where sensitive data should not be exposed.
5+
*/
26
package redact
37

48
import (

pkg/retrier/retrier.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
// Package retrier allow to retry execute a function in case of errors.
1+
/*
2+
Package retrier provides the ability to automatically repeat a user-defined function based on the error status.
3+
4+
The default behavior is to retry in case of any error.
5+
6+
This package also offers ready-made DefaultRetryIf function that can be used for most cases.
7+
8+
Additionally, it allows you to set the maximum number of retries,
9+
the delay after the first failed attempt,
10+
the time multiplication factor to determine the successive delay value,
11+
and the jitter used to introduce randomness and avoid request collisions.
12+
*/
213
package retrier
314

415
import (
@@ -46,6 +57,7 @@ type Retrier struct {
4657
taskError error
4758
}
4859

60+
// defaultRetrier returns a new instance of Retrier with default configuration values.
4961
func defaultRetrier() *Retrier {
5062
return &Retrier{
5163
attempts: DefaultAttempts,
@@ -100,6 +112,8 @@ func (r *Retrier) Run(ctx context.Context, task TaskFn) error {
100112
}
101113
}
102114

115+
// setTimer sets the timer for the Retrier with the given duration.
116+
// If the timer is already running, it is stopped and the timer channel is drained before resetting.
103117
func (r *Retrier) setTimer(d time.Duration) {
104118
if !r.timer.Stop() {
105119
// make sure to drain timer channel before reset
@@ -112,6 +126,9 @@ func (r *Retrier) setTimer(d time.Duration) {
112126
r.timer.Reset(d)
113127
}
114128

129+
// exec executes the given task function with a timeout and handles retries if necessary.
130+
// It returns true if the task should not be retried or if the maximum number of attempts has been reached.
131+
// Otherwise, it returns false to indicate that the task should be retried.
115132
func (r *Retrier) exec(ctx context.Context, task TaskFn) bool {
116133
tctx, cancel := context.WithTimeout(ctx, r.timeout)
117134
r.taskError = task(tctx)

pkg/s3/s3.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
// Package s3 provides a client for AWS S3 bucket.
1+
/*
2+
Package s3 provides a simple client to interact with a AWS S3 bucket, including the ability to upload, download, and delete objects.
3+
4+
It is based on the official aws-sdk-go-v2 library.
5+
*/
26
package s3

pkg/slack/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Package slack is a basic Slack API client to send messages via a Webhook.
21
package slack
32

43
import (
@@ -44,7 +43,8 @@ type Client struct {
4443
}
4544

4645
// New creates a new instance of the Slack service client.
47-
// The arguments other than "addr" are optional. They can be set in the Webhook configuration or in each individual message.
46+
// The arguments other than "addr" (Slack Webhook URL) are optional,
47+
// they can be set in the Webhook configuration or in each individual message.
4848
func New(addr, username, iconEmoji, iconURL, channel string, opts ...Option) (*Client, error) {
4949
address, err := url.Parse(addr)
5050
if err != nil {

pkg/slack/slack.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*
2+
Package slack is a basic client for the official Slack API to send messages via a Webhook.
3+
4+
Ref.: https://api.slack.com/messaging/webhooks
5+
*/
6+
package slack

pkg/sleuth/sleuth.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
// Package sleuth contains the implementation of a basic Sleuth.io API client.
2-
// Ref.: https://help.sleuth.io/sleuth-api
1+
/*
2+
Package sleuth is a basic client for the official Sleuth.io API to register deployments, manual changes, custom incident impact, and custom metric impact.
3+
4+
Ref.: https://help.sleuth.io/sleuth-api
5+
*/
36
package sleuth
47

58
import (

0 commit comments

Comments
 (0)