daprstatestore

package module
v0.0.0-...-3b7ffb4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

daprstatestore

based on https://github.com/boj/redistore/tree/master

#iniciar dapr sidecar local sin la app nodejs. Esto deja ocupada la terminal, debe inicar otra terminal para ejecutar otros comandos
dapr run --log-level debug --app-id daprstatestore-test --dapr-http-port 47777 --dapr-grpc-port 63337 --resources-path "./components4test"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DaprStateStore

type DaprStateStore struct {
	Client         *dapr.Client
	StateStoreName string
	Codecs         []securecookie.Codec
	Options        *sessions.Options // default configuration
	DefaultMaxAge  int               // default Redis TTL for a MaxAge == 0 session
	// contains filtered or unexported fields
}

DaprStateStore stores sessions in a Dapr State Store backend.

func NewDaprStateStore

func NewDaprStateStore(stateStoreName string, keyPairs ...[]byte) (*DaprStateStore, error)

NewDaprStateStore returns a new DaprStateStore. size: maximum number of idle connections.

func (*DaprStateStore) Get

func (s *DaprStateStore) Get(r *http.Request, name string) (*sessions.Session, error)

Get returns a session for the given name after adding it to the registry.

See gorilla/sessions FilesystemStore.Get().

func (*DaprStateStore) New

func (s *DaprStateStore) New(r *http.Request, name string) (*sessions.Session, error)

New returns a session for the given name without adding it to the registry.

See gorilla/sessions FilesystemStore.New().

func (*DaprStateStore) Save

Save adds a single session to the response.

func (*DaprStateStore) SetKeyPrefix

func (s *DaprStateStore) SetKeyPrefix(p string)

SetKeyPrefix set the prefix

func (*DaprStateStore) SetMaxAge

func (s *DaprStateStore) SetMaxAge(v int)

SetMaxAge restricts the maximum age, in seconds, of the session record both in database and a browser. This is to change session storage configuration. If you want just to remove session use your session `s` object and change it's `Options.MaxAge` to -1, as specified in

http://godoc.org/github.com/gorilla/sessions#Options

Default is the one provided by this package value - `sessionExpire`. Set it to 0 for no restriction. Because we use `MaxAge` also in SecureCookie crypting algorithm you should use this function to change `MaxAge` value.

func (*DaprStateStore) SetMaxLength

func (s *DaprStateStore) SetMaxLength(l int)

SetMaxLength sets DaprStateStore.maxLength if the `l` argument is greater or equal 0 maxLength restricts the maximum length of new sessions to l. If l is 0 there is no limit to the size of a session, use with caution. The default for a new DaprStateStore is 16KB. Default: 16KB,

func (*DaprStateStore) SetSerializer

func (s *DaprStateStore) SetSerializer(ss SessionSerializer)

SetSerializer sets the serializer

type GobSerializer

type GobSerializer struct{}

GobSerializer uses gob package to encode the session map

func (GobSerializer) Deserialize

func (s GobSerializer) Deserialize(d []byte, ss *sessions.Session) error

Deserialize back to map[interface{}]interface{}

func (GobSerializer) Serialize

func (s GobSerializer) Serialize(ss *sessions.Session) ([]byte, error)

Serialize using gob

type JSONSerializer

type JSONSerializer struct{}

JSONSerializer encode the session map to JSON.

func (JSONSerializer) Deserialize

func (s JSONSerializer) Deserialize(d []byte, ss *sessions.Session) error

Deserialize back to map[string]interface{}

func (JSONSerializer) Serialize

func (s JSONSerializer) Serialize(ss *sessions.Session) ([]byte, error)

Serialize to JSON. Will err if there are unmarshalable key values

type SessionSerializer

type SessionSerializer interface {
	Deserialize(d []byte, ss *sessions.Session) error
	Serialize(ss *sessions.Session) ([]byte, error)
}

SessionSerializer provides an interface hook for alternative serializers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL