Documentation
¶
Overview ¶
Package contract provides interfaces and types for Gopi frame.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arrayable ¶
type Arrayable[E any] interface { // ToArray converts to array ToArray() []E }
Arrayable arrayable
type BlockingQueue ¶
type BlockingQueue[E any] interface { Queue[E] // TryEnqueue tries to enqueue element to the end of the queue TryEnqueue(E) bool // TryDequeue tries to dequeue the first element and return it TryDequeue() (E, bool) // EnqueueTimeout enqueues element to the end of the queue, // it will return false when timeout EnqueueTimeout(E, time.Duration) bool // DequeueTimeout dequeues the first element, // it will return zero value and false when timeout DequeueTimeout(time.Duration) (E, bool) }
BlockingQueue blocking queue interface
type Countable ¶
type Countable interface { // Count returns the count Count() int64 }
Countable countable
type Delayable ¶
type Delayable[T any] interface { json.Marshaler json.Unmarshaler // Until returns the available time Until() time.Time // Value returns the underlying value Value() T }
Delayable delayable
type DelayedQueue ¶
type DelayedQueue[E any] interface { Countable Arrayable[Delayable[E]] Jsonable json.Marshaler json.Unmarshaler Stringable IsEmpty() bool IsNotEmpty() bool Clear() Peek() (Delayable[E], bool) Enqueue(Delayable[E]) bool Dequeue() (Delayable[E], bool) TryDequeue() (Delayable[E], bool) DequeueTimeout(time.Duration) (Delayable[E], bool) }
type List ¶
type List[E any] interface { Countable Sortable[E] Traversable[int, E] Reversible Stringable Jsonable Arrayable[E] json.Marshaler json.Unmarshaler // IsEmpty returns whether the list is empty. IsEmpty() bool // IsNotEmpty returns whether the list is not empty. IsNotEmpty() bool // Contains returns whether the list contains the specific element. Contains(E) bool // ContainsWhere returns whether the list contains specific elements by callback. ContainsWhere(func(E) bool) bool // Push pushes elements into the list. Push(...E) // Remove removes the specific element. Remove(E) // RemoveAt removes the element on the specific index. RemoveAt(int) // RemoveWhere removes specific elements by callback. RemoveWhere(func(E) bool) // Clear clears the list. Clear() // Get returns the element on the specific index. Get(int) E // Set sets element on the specific index. Set(int, E) // First returns the first element of the list. // it will return a zero value and false when the list is empty. First() (E, bool) // FirstOr returns the first element of the list, it will return the default value when the list is empty. FirstOr(E) E // FirstWhere returns the first element of the list which matches the callback. // It will return a zero value and false when none matches the callback. FirstWhere(func(E) bool) (E, bool) // FirstWhereOr returns the first element of the list which matches the callback. // It will return the default value when none matches the callback. FirstWhereOr(func(E) bool, E) E // Last returns the last element of the list. // It will return a zero value and false when the list is empty. Last() (E, bool) // LastOr returns the last element of the list. // It will return the default value when the list is empty. LastOr(E) E // LastWhere returns the last element of the list which matches the callback. // It will return a zero value and false when none matches the callback. LastWhere(func(E) bool) (E, bool) // LastWhereOr returns the last element of the list which matches the callback. // It will return the default value when none matches the callback. LastWhereOr(func(E) bool, E) E // Pop removes the last element of the list and returns it. // It will return a zero value and false when the list is empty. Pop() (E, bool) // Shift removes the first element of the list and returns it. // It will return a zero value and false when the list is empty. Shift() (E, bool) // Unshift puts elements to the head of the list. Unshift(...E) // IndexOf returns the index of the specific element. IndexOf(E) int // IndexOfWhere returns the index of the first element which matches the callback. IndexOfWhere(func(E) bool) int // Compact makes the list more compact Compact(eq func(E, E) bool) // Min returns the min element Min(func(E, E) int) E // Max returns the max element Max(func(E, E) int) E }
List list
type Map ¶
type Map[K comparable, V any] interface { Countable Traversable[K, V] Jsonable json.Marshaler json.Unmarshaler Mappable[K, V] Stringable // IsEmpty returns whether the map is empty. IsEmpty() bool // IsNotEmpty returns whether the map is not empty. IsNotEmpty() bool // Get returns the value of the specific key. // It will return a zero value and false when the map is empty. Get(K) (V, bool) // GetOr returns the value of the specific key. // It will return the default value when the map is empty. GetOr(K, V) V // Set sets value to specific key. Set(K, V) // Remove removes specific key. Remove(K) // Keys returns all keys. Keys() []K // Values returns all values. Values() []V // Clear clears map. Clear() // ContainsKey returns whether the map contains specific key. ContainsKey(K) bool // Contains returns whether the map contains specific value. Contains(V) bool // ContainsWhere returns whether the map contains value which matches the callback. ContainsWhere(func(V) bool) bool }
Map map
type Mappable ¶
type Mappable[K comparable, V any] interface { // ToMap converts to map ToMap() map[K]V }
Mappable mappable
type Queue ¶
type Queue[E any] interface { Countable Arrayable[E] Jsonable json.Marshaler json.Unmarshaler Stringable // IsEmpty returns whether the queue is empty IsEmpty() bool // IsNotEmpty returns whether the queue is not empty IsNotEmpty() bool // Clear clears the queue Clear() // Peek returns the first element of the queue. Peek() (E, bool) // Enqueue enqueues element to the end of the queue Enqueue(E) bool // Dequeue dequeues the first element Dequeue() (E, bool) // Remove removes the specific element Remove(E) // RemoveWhere removes the elements which matches the callback RemoveWhere(func(E) bool) }
Queue queue interface
type Set ¶
type Set[E comparable] interface { Countable Traversable[int, E] Arrayable[E] Jsonable json.Marshaler json.Unmarshaler Stringable // IsEmpty returns whether the set is empty IsEmpty() bool // IsNotEmpty returns whether the set is not empty IsNotEmpty() bool // Contains returns whether the set contains specific element Contains(E) bool // ContainsWhere returns whether the set contains element which matches the callback ContainsWhere(func(E) bool) bool // Push pushes elements to set Push(...E) // Remove removes the specific element Remove(E) // RemoveWhere removes elements which matches the callback RemoveWhere(func(E) bool) // Clear clears the set Clear() }
Set sets
type Traversable ¶
type Traversable[K any, V any] interface { // Each travers, if the callback returns false then break Each(func(key K, value V) bool) }
Traversable traversable
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
app
module
|
|
cache
module
|
|
console
module
|
|
container
module
|
|
database
module
|
|
enum
module
|
|
eventbus
module
|
|
exception
module
|
|
filesystem
module
|
|
logger
module
|
|
paginator
module
|
|
pipeline
module
|
|
queue
module
|
|
redis
module
|
|
repository
module
|
|
response
module
|
|
router
module
|
|
server
module
|
|
translator
module
|
|
validation
module
|
|
websocket
module
|
|
writer
module
|
Click to show internal directories.
Click to hide internal directories.