Skip to content

Commit 68dbe34

Browse files
committed
comments for godoc
1 parent 3ca0706 commit 68dbe34

File tree

5 files changed

+37
-15
lines changed

5 files changed

+37
-15
lines changed

credentials/credentials.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
package credentials
22

33
import (
4+
"context"
45
"github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials"
56
)
67

7-
type Credentials = credentials.Credentials
8+
// Credentials is an interface of YDB credentials required for connect with YDB
9+
type Credentials interface {
10+
// Token must return actual token or error
11+
Token(context.Context) (string, error)
12+
}
813

914
type optionsHolder struct {
1015
sourceInfo string
1116
}
1217

1318
type option func(h *optionsHolder)
1419

20+
// WithSourceInfo option append to credentials object the source info for reporting source info details on error case
1521
func WithSourceInfo(sourceInfo string) option {
1622
return func(h *optionsHolder) {
1723
h.sourceInfo = sourceInfo
1824
}
1925
}
2026

27+
// NewAccessTokenCredentials makes access token credentials object
28+
// Passed options redefines default values of credentials object internal fields
2129
func NewAccessTokenCredentials(accessToken string, opts ...option) Credentials {
2230
h := &optionsHolder{
2331
sourceInfo: "credentials.NewAccessTokenCredentials(token)",
@@ -28,6 +36,8 @@ func NewAccessTokenCredentials(accessToken string, opts ...option) Credentials {
2836
return credentials.NewAccessTokenCredentials(accessToken, h.sourceInfo)
2937
}
3038

39+
// NewAnonymousCredentials makes anonymous credentials object
40+
// Passed options redefines default values of credentials object internal fields
3141
func NewAnonymousCredentials(opts ...option) Credentials {
3242
h := &optionsHolder{
3343
sourceInfo: "credentials.NewAnonymousCredentials()",

errors.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,33 @@ import (
1010
"github.com/ydb-platform/ydb-go-sdk/v3/ratelimiter"
1111
)
1212

13-
// IterateByIssues helps to iterate over internal issues of operation error
13+
// IterateByIssues helps to iterate over internal issues of operation error.
1414
func IterateByIssues(err error, it func(message string, code Ydb.StatusIds_StatusCode, severity uint32)) {
1515
xerrors.IterateByIssues(err, it)
1616
}
1717

18-
// IsTimeoutError checks whether given err is a some timeout error (context, transport or operation)
18+
// IsTimeoutError checks whether given err is a some timeout error (context, transport or operation).
1919
func IsTimeoutError(err error) bool {
2020
return xerrors.IsTimeoutError(err)
2121
}
2222

23-
// IsTransportError checks whether given err is a transport (grpc) error
23+
// IsTransportError checks whether given err is a transport (grpc) error.
2424
func IsTransportError(err error, codes ...grpcCodes.Code) bool {
2525
return xerrors.IsTransportError(err, codes...)
2626
}
2727

28-
// Error is an interface of error which reports about error code and error name
29-
type Error xerrors.Error
28+
// Error is an interface of error which reports about error code and error name.
29+
type Error interface {
30+
error
3031

31-
// TransportError checks when given error is a transport error and returns description of transport error
32+
// Code reports the error code
33+
Code() int32
34+
35+
// Name reports the name of error
36+
Name() string
37+
}
38+
39+
// TransportError checks when given error is a transport error and returns description of transport error.
3240
func TransportError(err error) Error {
3341
return xerrors.TransportError(err)
3442
}
@@ -38,14 +46,14 @@ func IsYdbError(err error) bool {
3846
return xerrors.IsYdb(err)
3947
}
4048

41-
// IsOperationError reports whether any error is an operation error with one of passed codes
42-
// If codes not defined IsOperationError returns true on error is an operation error
49+
// IsOperationError reports whether any error is an operation error with one of passed codes.
50+
// If codes not defined IsOperationError returns true on error is an operation error.
4351
func IsOperationError(err error, codes ...Ydb.StatusIds_StatusCode) bool {
4452
return xerrors.IsOperationError(err, codes...)
4553
}
4654

47-
// OperationError returns operation error description
48-
// If given err is not an operation error - returns nil
55+
// OperationError returns operation error description.
56+
// If given err is not an operation error - returns nil.
4957
func OperationError(err error) Error {
5058
return xerrors.OperationError(err)
5159
}
@@ -80,7 +88,7 @@ func IsRatelimiterAcquireError(err error) bool {
8088
return ratelimiterErrors.IsAcquireError(err)
8189
}
8290

83-
// ToRatelimiterAcquireError casts given err to ratelimiter.AcquireError
91+
// ToRatelimiterAcquireError casts given err to ratelimiter.AcquireError.
8492
// If given err is not ratelimiter acquire error - returns nil
8593
func ToRatelimiterAcquireError(err error) ratelimiter.AcquireError {
8694
return ratelimiterErrors.ToAcquireError(err)

internal/credentials/credentials.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212
// not send any token meta information during request.
1313
var errNoCredentials = xerrors.Wrap(fmt.Errorf("ydb: credentials: no credentials"))
1414

15-
// Credentials is an interface that contains options used to authorize a
16-
// client.
15+
// Credentials is an interface of YDB credentials required for connect with YDB
1716
type Credentials interface {
17+
// Token must return actual token or error
1818
Token(context.Context) (string, error)
1919
}
2020

internal/xerrors/xerrors.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ import (
1010
"github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
1111
)
1212

13+
// Error is an interface of error which reports about error code and error name.
1314
type Error interface {
1415
error
1516

17+
// Code reports the error code
1618
Code() int32
19+
20+
// Name reports the name of error
1721
Name() string
1822
}
1923

version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ package ydb
22

33
import "github.com/ydb-platform/ydb-go-sdk/v3/internal/meta"
44

5-
// Version is the current version of sdk
5+
// Version reports current version of sdk
66
const Version = meta.Version

0 commit comments

Comments
 (0)