Documentation
¶
Overview ¶
Package ccc contains utility types and functions
Index ¶
- Variables
- func BatchIter2[T any](iter2 iter.Seq2[T, error], size int) iter.Seq[iter.Seq2[T, error]]
- func Must[T any](value T, err error) T
- func NextIter[T any](r NextIterator[T]) iter.Seq2[T, error]
- func Ptr[T any](t T) *Tdeprecated
- func ReadIter[T any](r ReadIterator[T]) iter.Seq2[T, error]
- func StartTrace(ctx context.Context) (context.Context, trace.Span)deprecated
- type Duration
- type JSONMap
- type NextIterator
- type NullDuration
- func (d *NullDuration) DecodeSpanner(val any) error
- func (d NullDuration) EncodeSpanner() (any, error)
- func (d NullDuration) MarshalJSON() ([]byte, error)
- func (d NullDuration) MarshalText() ([]byte, error)
- func (d *NullDuration) UnmarshalJSON(b []byte) error
- func (d *NullDuration) UnmarshalText(text []byte) error
- type NullEnum
- func (n *NullEnum[T]) DecodeSpanner(val any) error
- func (n NullEnum[T]) EncodeSpanner() (any, error)
- func (n NullEnum[T]) MarshalJSON() ([]byte, error)
- func (n NullEnum[T]) MarshalText() ([]byte, error)
- func (n *NullEnum[T]) UnmarshalJSON(b []byte) error
- func (n *NullEnum[T]) UnmarshalText(text []byte) error
- type NullUUID
- func (u *NullUUID) DecodeSpanner(val any) error
- func (u NullUUID) EncodeSpanner() (any, error)
- func (u NullUUID) IsNil() bool
- func (u NullUUID) MarshalJSON() ([]byte, error)
- func (u NullUUID) MarshalText() ([]byte, error)
- func (u *NullUUID) UnmarshalJSON(data []byte) error
- func (u *NullUUID) UnmarshalText(text []byte) error
- type ReadIterator
- type UUID
Constants ¶
This section is empty.
Variables ¶
var NilUUID = UUID{}
NilUUID represents the nil value of UUID
Functions ¶
func BatchIter2 ¶ added in v0.2.14
BatchIter2 takes an iter.Seq2 and returns an iter.Seq of iter.Seq2, where each inner iter.Seq2 yields a batch of T of the specified size.
BatchIter2 returns a single-use iterator, but can take in a reusable iterator.
The inner batch iterator must be ranged over with a range loop (or iter.Pull) before the next outer iterator can be accessed. It is acceptable to break early from a range loop, in which case the remaining items will be returned by the next outer iterator. If the inner iterator is not propery ranged over, the outer iterator will panic.
If the provided size is not a positive integer, the returned iterator will yield a single error.
Example:
for batch := range BatchIter2(myIter, 10) {
// Do some operation between batches such as start a new db transaction
for resource, err := range batch {
if err != nil {
log.Fatal(err)
}
fmt.Println(resource)
}
}
func NextIter ¶ added in v0.2.14
func NextIter[T any](r NextIterator[T]) iter.Seq2[T, error]
NextIter returns a reusable iter.Seq2 iterator from anything that implements the NextIterator interface.
func ReadIter ¶ added in v0.2.14
func ReadIter[T any](r ReadIterator[T]) iter.Seq2[T, error]
ReadIter returns a reusable iter.Seq2 iterator from anything that implements the ReadIterator interface.
func StartTrace
deprecated
added in
v0.2.15
StartTrace uses runtime reflection to determine the fully qualified package path and the function/method name of the caller.
The Tracer name is set to the fully qualified package path (e.g., "github.com/cccteam/ccc"). The Span name is set to the short function name (e.g., "Struct.Method()").
Deprecated: Use github.com/cccteam/ccc/tracer.Start instead
Types ¶
type Duration ¶ added in v0.2.8
Duration represents the elapsed time between two instants as an int64 nanosecond count. The representation limits the largest representable duration to approximately 290 years. This custom type provides support for marshaling to and from text, json, and Spanner.
func NewDuration ¶ added in v0.2.9
NewDuration returns a Duration from a time.Duration
func NewDurationFromString ¶ added in v0.2.9
NewDurationFromString parses a Duration from a string representation in the same manner as time.ParseDuration(), but with the added step of removing any whitespace from the string.
func (*Duration) DecodeSpanner ¶ added in v0.2.8
DecodeSpanner implements the spanner.Decoder interface
func (Duration) EncodeSpanner ¶ added in v0.2.8
EncodeSpanner implements the spanner.Encoder interface
func (Duration) MarshalJSON ¶ added in v0.2.8
MarshalJSON implements json.Marshaler interface for Duration.
func (Duration) MarshalText ¶ added in v0.2.8
MarshalText implements the encoding.TextMarshaler interface
func (*Duration) UnmarshalJSON ¶ added in v0.2.8
UnmarshalJSON implements json.Unmarshaler.UnmarshalJSON for Duration.
func (*Duration) UnmarshalText ¶ added in v0.2.8
UnmarshalText implements the encoding.Unmarshaler interface
type JSONMap ¶
JSONMap is a map that can be unmarshalled from JSON, converting all json.Number values to their appropriate int or float64 types.
func (*JSONMap) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface
type NextIterator ¶ added in v0.2.14
NextIterator implements an interface where each Next() yields the next item from the Reader, with Error() returning any problems that occur during the Next() call. This iterator will start with a Next() call. If Next() returns true, it will call Value(). This will continue until Next() returns false, at which point it will call Error() one time.
type NullDuration ¶ added in v0.2.9
NullDuration handles null values of the Duration type
func NewNullDuration ¶ added in v0.2.9
func NewNullDuration(d time.Duration) NullDuration
NewNullDuration returns a NullDuration from a time.Duration
func NewNullDurationFromString ¶ added in v0.2.9
func NewNullDurationFromString(s string) (NullDuration, error)
NewNullDurationFromString parses a NullDuration from a string representation
func (*NullDuration) DecodeSpanner ¶ added in v0.2.9
func (d *NullDuration) DecodeSpanner(val any) error
DecodeSpanner implements the spanner.Decode interface
func (NullDuration) EncodeSpanner ¶ added in v0.2.9
func (d NullDuration) EncodeSpanner() (any, error)
EncodeSpanner implements the spanner.Encode interface
func (NullDuration) MarshalJSON ¶ added in v0.2.9
func (d NullDuration) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface for Duration.
func (NullDuration) MarshalText ¶ added in v0.2.9
func (d NullDuration) MarshalText() ([]byte, error)
MarshalText implements the encoder.TextMarshaler interface
func (*NullDuration) UnmarshalJSON ¶ added in v0.2.9
func (d *NullDuration) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.UnmarshalJSON for Duration.
func (*NullDuration) UnmarshalText ¶ added in v0.2.9
func (d *NullDuration) UnmarshalText(text []byte) error
UnmarshalText implements the encoder.TextUnmarshaler interface
type NullEnum ¶ added in v0.2.12
NullEnum represents a generic enum that may be null. NullEnum implements the Spanner (DecodeSpanner, EncodeSpanner), JSON (MarshalJSON, UnmarshalJSON), and Text (MarshalText, UnmarshalText) interfaces.
func (*NullEnum[T]) DecodeSpanner ¶ added in v0.2.12
DecodeSpanner implements the spanner.Decoder interface
func (NullEnum[T]) EncodeSpanner ¶ added in v0.2.12
EncodeSpanner implements the spanner.Encoder interface
func (NullEnum[T]) MarshalJSON ¶ added in v0.2.12
MarshalJSON implements json.Marshaler interface for NullEnum.
func (NullEnum[T]) MarshalText ¶ added in v0.2.12
MarshalText implements the encoding.TextMarshaler interface
func (*NullEnum[T]) UnmarshalJSON ¶ added in v0.2.12
UnmarshalJSON implements json.Unmarshaler.UnmarshalJSON for NullEnum.
func (*NullEnum[T]) UnmarshalText ¶ added in v0.2.12
UnmarshalText implements the encoding.TextUnmarshaler interface
type NullUUID ¶
NullUUID represents a UUID that may be null. NullUUID implements the Spanner (DecodeSpanner, EncodeSpanner), JSON (MarshalJSON, UnmarshalJSON), and Text (MarshalText, UnmarshalText) interfaces.
func NullUUIDFromString ¶
NullUUIDFromString parses a NullUUID from a string representation
func NullUUIDFromUUID ¶
NullUUIDFromUUID returns a NullUUID from a UUID
func (*NullUUID) DecodeSpanner ¶
DecodeSpanner implements the spanner.Decoder interface
func (NullUUID) EncodeSpanner ¶
EncodeSpanner implements the spanner.Encoder interface
func (NullUUID) MarshalJSON ¶ added in v0.2.3
MarshalJSON implements json.Marshaler interface for NullUUID.
func (NullUUID) MarshalText ¶ added in v0.2.3
MarshalText implements the encoding.TextMarshaler interface
func (*NullUUID) UnmarshalJSON ¶ added in v0.2.3
UnmarshalJSON implements json.Unmarshaler.UnmarshalJSON for NullUUID.
func (*NullUUID) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface
type ReadIterator ¶ added in v0.2.14
ReadIterator implements an interface where each Read() yields the next item from the Reader, with err returning any problems that occur during the Read() call. The semantics of how the end of stream is signaled is left up to the implementation.
This can be used to convert the csv.Read() to an iter.Seq2 as an example.
type UUID ¶
UUID represents a UUID. UUID implements the Spanner (DecodeSpanner, EncodeSpanner), JSON (MarshalJSON, UnmarshalJSON), and Text (MarshalText, UnmarshalText) interfaces.
func UUIDFromString ¶
UUIDFromString parses a UUID from a string representation
func (*UUID) DecodeSpanner ¶
DecodeSpanner implements the spanner.Decoder interface
func (UUID) EncodeSpanner ¶
EncodeSpanner implements the spanner.Encoder interface
func (UUID) MarshalJSON ¶ added in v0.2.3
MarshalJSON implements json.Marshaler interface for UUID.
func (UUID) MarshalText ¶ added in v0.2.3
MarshalText implements the encoding.TextMarshaler interface
func (*UUID) UnmarshalJSON ¶ added in v0.2.3
UnmarshalJSON implements json.Unmarshaler.UnmarshalJSON for UUID.
func (*UUID) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
accesstypes
module
|
|
|
cache
module
|
|
|
ccclint
module
|
|
|
columnset
module
|
|
|
lint
module
|
|
|
linters
|
|
|
otelspanname
module
|
|
|
middleware
module
|
|
|
patchset
module
|
|
|
pkg
module
|
|
|
resource
module
|
|
|
resourceset
module
|
|
|
resourcestore
module
|
|
|
securehash
module
|
|
|
sns
module
|
|
|
tracer
module
|