Server sessions
Technical reference of Sesiones del servidor.
This API is used in Sessions configuration.
Symbols
| Symbol | Class | Description |
|---|---|---|
| ErrSessionNotAvailable | var | ErrSessionNotAvailable it exposes a shared value of the package. |
| ErrSessionInvalidKey | var | ErrSessionInvalidKey it exposes a shared value of the package. |
| ErrSessionInvalidOut | var | ErrSessionInvalidOut it exposes a shared value of the package. |
| ErrSessionExpired | var | ErrSessionExpired it exposes a shared value of the package. |
| SessionConfig | type | SessionConfig defines a public type of API. |
| SessionStorage | type | SessionStorage defines a public type of API. |
| SessionStorageConfig | type | SessionStorageConfig defines a public type of API. |
| SessionStorageRuntime | type | SessionStorageRuntime defines a public type of API. |
| SessionOpenStatus | type | SessionOpenStatus defines a public type of API. |
| SessionOpenMissing | const | SessionOpenMissing defines a constant value of the API. |
| SessionOpenOpened | const | SessionOpenOpened defines a constant value of the API. |
| SessionOpenInvalidToken | const | SessionOpenInvalidToken defines a constant value of the API. |
| SessionOpenExpired | const | SessionOpenExpired defines a constant value of the API. |
| SessionOpenRequest | type | SessionOpenRequest defines a public type of API. |
| SessionOpenResult | type | SessionOpenResult defines a public type of API. |
| SessionOpenResult.Opened | func | Open up. Opened. |
| SessionStorageInstance | type | SessionStorageInstance defines a public type of API. |
| SessionMeta | type | SessionMeta defines a public type of API. |
| SessionExpireFunc | type | SessionExpireFunc defines a public type of API. |
| SessionEventKind | type | SessionEventKind defines a public type of API. |
| SessionEventExpired | const | SessionEventExpired defines a constant value of the API. |
| SessionEventDestroyed | const | SessionEventDestroyed defines a constant value of the API. |
| SessionEvent | type | SessionEvent defines a public type of API. |
| SessionEventFunc | type | SessionEventFunc defines a public type of API. |
| SessionRotateFunc | type | SessionRotateFunc defines a public type of API. |
| SessionDestroyFunc | type | SessionDestroyFunc defines a public type of API. |
| SessionSaveFunc | type | SessionSaveFunc defines a public type of API. |
| Session | type | Session defines a public type of API. |
| ExpireSession | type | ExpireSession defines a public type of API. |
| NewSession | func | Build NewSession. |
| NewSessionReference | func | Build NewSessionReference. |
| NewSessionWithRotate | func | Build NewSessionWithRotate. |
| NewSessionWithLifecycle | func | Build NewSessionWithLifecycle. |
| DetachSession | func | It creates a life-cycle session without callbacks. |
| Session.ID | func | Return the identifier. |
| Session.Token | func | Give back the session token. |
| Session.Destroy | func | Destroy the session and block new mutations. |
| Session.IsDestroyed | func | Indicates the state of IsDestroyed. |
| NewExpireSession | func | Build NewExpireSession. |
| ExpireSession.ID | func | Return the identifier. |
| ExpireSession.Token | func | Give back the session token. |
| ExpireSession.CreatedAt | func | Crea CreatedAt. |
| ExpireSession.LastUpdate | func | Returns the instant of the latest update. |
| ExpireSession.ExpireAt | func | It returns the moment of expiry. |
| ExpireSession.Get | func | It gets the first value associated with a key. |
| ExpireSession.Has | func | It indicates whether the collection contains the key. |
| ExpireSession.GetAll | func | It gets all the values associated with a key. |
| ExpireSession.GetTTL | func | Get it. GetTTL. |
| Session.Get | func | It gets the first value associated with a key. |
| Session.Set | func | Set or replace a value. |
| Session.Has | func | It indicates whether the collection contains the key. |
| Session.GetAll | func | It gets all the values associated with a key. |
| Session.Delete | func | Eliminates the value associated with a key. |
| Session.Rotate | func | Rota Rotate. |
| Session.Clear | func | Clean Clear. |
| Session.Save | func | The remaining changes remain. |
| Session.SetTTL | func | Sets SetTTL. |
| Session.GetTTL | func | Get it. GetTTL. |
| MemorySessionAdapter | type | MemorySessionAdapter defines a public type of API. |
| NewMemorySessionAdapter | func | Build NewMemorySessionAdapter. |
| MemorySessionStorage | func | Returns the session storage in memory. |
| MemorySessionAdapter.GetName | func | Get it. GetName. |
| MemorySessionAdapter.OpenSessionStorage | func | Open up. OpenSessionStorage. |
| SessionTrace | type | SessionTrace defines a public type of API. |
| SessionTraceField | type | SessionTraceField defines a public type of API. |
| SessionTraceStage | type | SessionTraceStage defines a public type of API. |
| NewSessionTrace | func | Build NewSessionTrace. |
| SessionTrace.Now | func | Returns the watch used by the track. |
| SessionTrace.Add | func | Add Add. |
| SessionTrace.AddDuration | func | Add AddDuration. |
| SessionTrace.AddField | func | Add AddField. |
| SessionTrace.AddBool | func | Add AddBool. |
| SessionTrace.Fields | func | Give back a copy of the trace fields. |
| SessionTrace.Stages | func | Returns a copy of the tracks. |
ErrSessionNotAvailable
Declaration:
ErrSessionNotAvailable = errors.New("session is not available") ErrSessionNotAvailable it exposes a shared value of the package.
ErrSessionInvalidKey
Declaration:
ErrSessionInvalidKey = errors.New("session key is invalid") ErrSessionInvalidKey it exposes a shared value of the package.
ErrSessionInvalidOut
Declaration:
ErrSessionInvalidOut = errors.New("session output target is invalid") ErrSessionInvalidOut it exposes a shared value of the package.
ErrSessionExpired
Declaration:
ErrSessionExpired = errors.New("session is expired") ErrSessionExpired it exposes a shared value of the package.
SessionConfig
Declaration:
type SessionConfig struct {
TTL time.Duration
OnCreate func(session *Session)
OnExpire func(session *ExpireSession)
} SessionConfig defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
TTL | time.Duration | Life time. |
OnCreate | func(session *Session) | Public data associated with OnCreate. |
OnExpire | func(session *ExpireSession) | Public data associated with OnExpire. |
SessionStorage
Declaration:
type SessionStorage interface {
GetName() string
OpenSessionStorage(ctx context.Context, config SessionStorageConfig) (SessionStorageRuntime, error)
} SessionStorage defines a public type of API.
SessionStorageConfig
Declaration:
type SessionStorageConfig struct {
ProjectName string
TTL time.Duration
} SessionStorageConfig defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
ProjectName | string | Name of the element. |
TTL | time.Duration | Life time. |
SessionStorageRuntime
Declaration:
type SessionStorageRuntime interface {
GetName() string
Close() error
OpenSession(ctx context.Context, request SessionOpenRequest) (SessionOpenResult, error)
GetSession(ctx context.Context, sessionID string) (SessionStorageInstance, error)
CreateSession(ctx context.Context, meta *SessionMeta) (SessionStorageInstance, error)
SaveSession(ctx context.Context, sessionID string) error
TouchSession(ctx context.Context, sessionID string, ttl time.Duration) error
DeleteSession(ctx context.Context, sessionID string) error
SubscribeSessionEvents(ctx context.Context, fn SessionEventFunc) error
} SessionStorageRuntime defines a public type of API.
SessionOpenStatus
Declaration:
type SessionOpenStatus uint8 SessionOpenStatus defines a public type of API.
SessionOpenMissing
Declaration:
SessionOpenMissing SessionOpenStatus = iota SessionOpenMissing defines a constant value of the API.
SessionOpenOpened
Declaration:
SessionOpenOpened SessionOpenOpened defines a constant value of the API.
SessionOpenInvalidToken
Declaration:
SessionOpenInvalidToken SessionOpenInvalidToken defines a constant value of the API.
SessionOpenExpired
Declaration:
SessionOpenExpired SessionOpenExpired defines a constant value of the API.
SessionOpenRequest
Declaration:
type SessionOpenRequest struct {
ID string
Token string
TTL time.Duration
Now time.Time
Trace *SessionTrace
} SessionOpenRequest defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
ID | string | Unique identifier. |
Token | string | Token associate. |
TTL | time.Duration | Life time. |
Now | time.Time | Public data associated with Now. |
Trace | *SessionTrace | Public data associated with Trace. |
SessionOpenResult
Declaration:
type SessionOpenResult struct {
Status SessionOpenStatus
Instance SessionStorageInstance
} SessionOpenResult defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
Status | SessionOpenStatus | Status of the operation. |
Instance | SessionStorageInstance | Associated jurisdiction. |
SessionOpenResult.Opened
Declaration:
func (r SessionOpenResult) Opened() bool Open up. Opened.
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
Usage syntax
value := sessionOpenResult.Opened() SessionStorageInstance
Declaration:
type SessionStorageInstance interface {
ID() string
Token() string
Get(key string, out any) (bool, error)
Has(key string) bool
GetAll() map[string]any
Set(key string, value any) error
Delete(key string) error
SetToken(token string) error
Clear() error
SetTTL(ttl time.Duration)
GetTTL() time.Duration
} SessionStorageInstance defines a public type of API.
SessionMeta
Declaration:
type SessionMeta struct {
ID string
Token string
TTL time.Duration
ExpireAt time.Time
CreatedAt time.Time
UpdatedAt time.Time
} SessionMeta defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
ID | string | Unique identifier. |
Token | string | Token associate. |
TTL | time.Duration | Life time. |
ExpireAt | time.Time | Time mark. |
CreatedAt | time.Time | Time mark. |
UpdatedAt | time.Time | Time mark. |
SessionExpireFunc
Declaration:
type SessionExpireFunc func(session *ExpireSession) SessionExpireFunc defines a public type of API.
SessionEventKind
Declaration:
type SessionEventKind uint8 SessionEventKind defines a public type of API.
SessionEventExpired
Declaration:
SessionEventExpired SessionEventKind = iota + 1 SessionEventExpired defines a constant value of the API.
SessionEventDestroyed
Declaration:
SessionEventDestroyed SessionEventDestroyed defines a constant value of the API.
SessionEvent
Declaration:
type SessionEvent struct {
Kind SessionEventKind
SessionID string
Session *ExpireSession
} SessionEvent defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
Kind | SessionEventKind | Event or state class. |
SessionID | string | Associated identifier. |
Session | *ExpireSession | Associated session. |
SessionEventFunc
Declaration:
type SessionEventFunc func(event SessionEvent) SessionEventFunc defines a public type of API.
SessionRotateFunc
Declaration:
type SessionRotateFunc func() (string, error) SessionRotateFunc defines a public type of API.
SessionDestroyFunc
Declaration:
type SessionDestroyFunc func() error SessionDestroyFunc defines a public type of API.
SessionSaveFunc
Declaration:
type SessionSaveFunc func() error SessionSaveFunc defines a public type of API.
Session
Declaration:
type Session struct {
// contiene campos internos
} Session defines a public type of API.
ExpireSession
Declaration:
type ExpireSession struct {
// contiene campos internos
} ExpireSession defines a public type of API.
NewSession
Declaration:
func NewSession(instance SessionStorageInstance) Session Build NewSession.
Parameters
| Parameter | Type | Description |
|---|---|---|
instance | SessionStorageInstance | Type value SessionStorageInstance required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | Session | Type value Session produced by the operation. |
Usage syntax
value := server.NewSession(value) NewSessionReference
Declaration:
func NewSessionReference(id string) Session Build NewSessionReference.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Type value string required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | Session | Type value Session produced by the operation. |
Usage syntax
value := server.NewSessionReference("id") NewSessionWithRotate
Declaration:
func NewSessionWithRotate(instance SessionStorageInstance, rotate SessionRotateFunc) Session Build NewSessionWithRotate.
Parameters
| Parameter | Type | Description |
|---|---|---|
instance | SessionStorageInstance | Type value SessionStorageInstance required by the operation. |
rotate | SessionRotateFunc | Type value SessionRotateFunc required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | Session | Type value Session produced by the operation. |
Usage syntax
value := server.NewSessionWithRotate(value, value) NewSessionWithLifecycle
Declaration:
func NewSessionWithLifecycle(instance SessionStorageInstance, rotate SessionRotateFunc, destroy SessionDestroyFunc, onDestroyed func(), save ...SessionSaveFunc) Session Build NewSessionWithLifecycle.
Parameters
| Parameter | Type | Description |
|---|---|---|
instance | SessionStorageInstance | Type value SessionStorageInstance required by the operation. |
rotate | SessionRotateFunc | Type value SessionRotateFunc required by the operation. |
destroy | SessionDestroyFunc | Type value SessionDestroyFunc required by the operation. |
onDestroyed | func() | Type value func() required by the operation. |
save | ...SessionSaveFunc | Type value ...SessionSaveFunc required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | Session | Type value Session produced by the operation. |
Usage syntax
value := server.NewSessionWithLifecycle(value, value, value, nil, value) DetachSession
Declaration:
func DetachSession(session Session) Session It creates a life-cycle session without callbacks.
Parameters
| Parameter | Type | Description |
|---|---|---|
session | Session | Type value Session required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | Session | Type value Session produced by the operation. |
Usage syntax
value := server.DetachSession(value) Session.ID
Declaration:
func (s *Session) ID() string Return the identifier.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := ctx.Session.ID() Session.Token
Declaration:
func (s *Session) Token() string Give back the session token.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := ctx.Session.Token() Session.Destroy
Declaration:
func (s *Session) Destroy() error Destroy the session and block new mutations.
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
Destroy returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
err := ctx.Session.Destroy() Session.IsDestroyed
Declaration:
func (s *Session) IsDestroyed() bool Indicates the state of IsDestroyed.
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
Usage syntax
value := ctx.Session.IsDestroyed() NewExpireSession
Declaration:
func NewExpireSession(meta *SessionMeta, instance SessionStorageInstance) ExpireSession Build NewExpireSession.
Parameters
| Parameter | Type | Description |
|---|---|---|
meta | *SessionMeta | Type value *SessionMeta required by the operation. |
instance | SessionStorageInstance | Type value SessionStorageInstance required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | ExpireSession | Type value ExpireSession produced by the operation. |
Usage syntax
value := server.NewExpireSession(nil, value) ExpireSession.ID
Declaration:
func (s *ExpireSession) ID() string Return the identifier.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := expireSession.ID() ExpireSession.Token
Declaration:
func (s *ExpireSession) Token() string Give back the session token.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := expireSession.Token() ExpireSession.CreatedAt
Declaration:
func (s *ExpireSession) CreatedAt() time.Time Crea CreatedAt.
Returns
| Return | Type | Description |
|---|---|---|
value | time.Time | Type value time.Time produced by the operation. |
Usage syntax
value := expireSession.CreatedAt() ExpireSession.LastUpdate
Declaration:
func (s *ExpireSession) LastUpdate() time.Time Returns the instant of the latest update.
Returns
| Return | Type | Description |
|---|---|---|
value | time.Time | Type value time.Time produced by the operation. |
Usage syntax
value := expireSession.LastUpdate() ExpireSession.ExpireAt
Declaration:
func (s *ExpireSession) ExpireAt() time.Time It returns the moment of expiry.
Returns
| Return | Type | Description |
|---|---|---|
value | time.Time | Type value time.Time produced by the operation. |
Usage syntax
value := expireSession.ExpireAt() ExpireSession.Get
Declaration:
func (s *ExpireSession) Get(key string, out any) (bool, error) It gets the first value associated with a key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | Key that identifies the value. |
out | any | Destination where the result is decoded. |
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
When the key does not exist, it returns the zero value of T and false.
Errors
Get returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
value, err := expireSession.Get("key", &value) ExpireSession.Has
Declaration:
func (s *ExpireSession) Has(key string) bool It indicates whether the collection contains the key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | Key that identifies the value. |
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
Usage syntax
value := expireSession.Has("key") ExpireSession.GetAll
Declaration:
func (s *ExpireSession) GetAll() map[string]any It gets all the values associated with a key.
Returns
| Return | Type | Description |
|---|---|---|
value | map[string]any | Type value map[string]any produced by the operation. |
Behavior
The returned slice is independent of the collection. When the key does not exist, it returns nil and false.
Usage syntax
value := expireSession.GetAll() ExpireSession.GetTTL
Declaration:
func (s *ExpireSession) GetTTL() time.Duration Get it. GetTTL.
Returns
| Return | Type | Description |
|---|---|---|
value | time.Duration | Type value time.Duration produced by the operation. |
Usage syntax
value := expireSession.GetTTL() Session.Get
Declaration:
func (s *Session) Get(key string, out any) (bool, error) It gets the first value associated with a key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | Key that identifies the value. |
out | any | Destination where the result is decoded. |
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
When the key does not exist, it returns the zero value of T and false.
Errors
Get returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
value, err := ctx.Session.Get("key", &value) Session.Set
Declaration:
func (s *Session) Set(key string, value any) error Set or replace a value.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | Key that identifies the value. |
value | any | Value to be stored or issued. |
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
Replace the values previously associated with the same key.
Errors
Set returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
err := ctx.Session.Set("key", value) Session.Has
Declaration:
func (s *Session) Has(key string) bool It indicates whether the collection contains the key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | Key that identifies the value. |
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
Usage syntax
value := ctx.Session.Has("key") Session.GetAll
Declaration:
func (s *Session) GetAll() map[string]any It gets all the values associated with a key.
Returns
| Return | Type | Description |
|---|---|---|
value | map[string]any | Type value map[string]any produced by the operation. |
Behavior
The returned slice is independent of the collection. When the key does not exist, it returns nil and false.
Usage syntax
value := ctx.Session.GetAll() Session.Delete
Declaration:
func (s *Session) Delete(key string) error Eliminates the value associated with a key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | Key that identifies the value. |
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
It has no effect when the key does not exist.
Errors
Delete returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
err := ctx.Session.Delete("key") Session.Rotate
Declaration:
func (s *Session) Rotate() error Rota Rotate.
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
Rotate returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
err := ctx.Session.Rotate() Session.Clear
Declaration:
func (s *Session) Clear() error Clean Clear.
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
Clear returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
err := ctx.Session.Clear() Session.Save
Declaration:
func (s *Session) Save() error The remaining changes remain.
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
Save returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
err := ctx.Session.Save() Session.SetTTL
Declaration:
func (s *Session) SetTTL(ttl time.Duration) Sets SetTTL.
Parameters
| Parameter | Type | Description |
|---|---|---|
ttl | time.Duration | Life time. |
Usage syntax
ctx.Session.SetTTL(time.Hour) Session.GetTTL
Declaration:
func (s *Session) GetTTL() time.Duration Get it. GetTTL.
Returns
| Return | Type | Description |
|---|---|---|
value | time.Duration | Type value time.Duration produced by the operation. |
Usage syntax
value := ctx.Session.GetTTL() MemorySessionAdapter
Declaration:
type MemorySessionAdapter struct{} MemorySessionAdapter defines a public type of API.
NewMemorySessionAdapter
Declaration:
func NewMemorySessionAdapter() SessionStorage Build NewMemorySessionAdapter.
Returns
| Return | Type | Description |
|---|---|---|
value | SessionStorage | Type value SessionStorage produced by the operation. |
Usage syntax
value := server.NewMemorySessionAdapter() MemorySessionStorage
Declaration:
func MemorySessionStorage() SessionStorage Returns the session storage in memory.
Returns
| Return | Type | Description |
|---|---|---|
value | SessionStorage | Type value SessionStorage produced by the operation. |
Usage syntax
value := server.MemorySessionStorage() MemorySessionAdapter.GetName
Declaration:
func (MemorySessionAdapter) GetName() string Get it. GetName.
Returns
| Return | Type | Description |
|---|---|---|
value | string | Textual value produced by the operation; its zero value is an empty string. |
Usage syntax
value := memorySessionAdapter.GetName() MemorySessionAdapter.OpenSessionStorage
Declaration:
func (MemorySessionAdapter) OpenSessionStorage(ctx context.Context, config SessionStorageConfig) (SessionStorageRuntime, error) Open up. OpenSessionStorage.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | context.Context | Context of execution. |
config | SessionStorageConfig | Type value SessionStorageConfig required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | SessionStorageRuntime | Type value SessionStorageRuntime produced by the operation. |
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
OpenSessionStorage returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
value, err := memorySessionAdapter.OpenSessionStorage(ctx, value) SessionTrace
Declaration:
type SessionTrace struct {
Enabled bool
} SessionTrace defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
Enabled | bool | Activate or disable the function. |
SessionTraceField
Declaration:
type SessionTraceField struct {
Name string
Value string
} SessionTraceField defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
Name | string | Name of the value. |
Value | string | Value stored. |
SessionTraceStage
Declaration:
type SessionTraceStage struct {
Name string
Duration time.Duration
} SessionTraceStage defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
Name | string | Name of the value. |
Duration | time.Duration | Length recorded. |
NewSessionTrace
Declaration:
func NewSessionTrace(enabled bool) *SessionTrace Build NewSessionTrace.
Parameters
| Parameter | Type | Description |
|---|---|---|
enabled | bool | Type value bool required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | *SessionTrace | Type value *SessionTrace produced by the operation. |
Usage syntax
value := server.NewSessionTrace(value) SessionTrace.Now
Declaration:
func (t *SessionTrace) Now() time.Time Returns the watch used by the track.
Returns
| Return | Type | Description |
|---|---|---|
value | time.Time | Type value time.Time produced by the operation. |
Usage syntax
value := sessionTrace.Now() SessionTrace.Add
Declaration:
func (t *SessionTrace) Add(name string, started time.Time) Add Add.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Name assigned. |
started | time.Time | Type value time.Time required by the operation. |
Usage syntax
sessionTrace.Add("name", value) SessionTrace.AddDuration
Declaration:
func (t *SessionTrace) AddDuration(name string, duration time.Duration) Add AddDuration.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Name assigned. |
duration | time.Duration | Type value time.Duration required by the operation. |
Usage syntax
sessionTrace.AddDuration("name", value) SessionTrace.AddField
Declaration:
func (t *SessionTrace) AddField(name string, value string) Add AddField.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Name assigned. |
value | string | Value to be stored or issued. |
Usage syntax
sessionTrace.AddField("name", value) SessionTrace.AddBool
Declaration:
func (t *SessionTrace) AddBool(name string, value bool) Add AddBool.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Name assigned. |
value | bool | Value to be stored or issued. |
Usage syntax
sessionTrace.AddBool("name", value) SessionTrace.Fields
Declaration:
func (t *SessionTrace) Fields() []SessionTraceField Give back a copy of the trace fields.
Returns
| Return | Type | Description |
|---|---|---|
value | []SessionTraceField | Result collection; can be nil when there are no values. |
Usage syntax
value := sessionTrace.Fields() SessionTrace.Stages
Declaration:
func (t *SessionTrace) Stages() []SessionTraceStage Returns a copy of the tracks.
Returns
| Return | Type | Description |
|---|---|---|
value | []SessionTraceStage | Result collection; can be nil when there are no values. |
Usage syntax
value := sessionTrace.Stages()