session

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2018 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTTL = "30s"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Key [suggested]
	//
	// Implementation-specific Key to be placed in session key.
	Key string

	// TTL [optional]
	//
	// Session TTL, defaults to value of DefaultTTL
	TTL string

	// Behavior [optional]
	//
	// Session timeout behavior, defaults to "release"
	Behavior string

	// Log [optional]
	//
	// Logger for this session.  One will be created if value is empty
	Log log.DebugLogger

	// Client [optional]
	//
	// Consul API client, default will be created if not provided
	Client *api.Client

	// UpdateFunc [optional]
	//
	// Callback to be executed after session state change
	UpdateFunc UpdateFunc

	// AutoRun [optional]
	//
	// Whether the session should start immediately after successful construction
	AutoRun bool
}

type NameParts

type NameParts struct {
	Key      string
	NodeName string
	RandomID string
}

func ParseName

func ParseName(name string) (*NameParts, error)

ParseName is provided so you don't have to parse it yourself :)

type Session

type Session struct {
	// contains filtered or unexported fields
}

func New

func New(conf *Config) (*Session, error)

func (*Session) Behavior

func (cs *Session) Behavior() string

func (*Session) ID

func (cs *Session) ID() string

func (*Session) Key

func (cs *Session) Key() string

func (*Session) LastRenewed

func (cs *Session) LastRenewed() time.Time

func (*Session) Name

func (cs *Session) Name() string

func (*Session) RenewInterval

func (cs *Session) RenewInterval() time.Duration

func (*Session) Run

func (cs *Session) Run()

func (*Session) Running

func (cs *Session) Running() bool

func (*Session) State

func (cs *Session) State() State

func (*Session) Stop

func (cs *Session) Stop() error

func (*Session) TTL

func (cs *Session) TTL() time.Duration

type State

type State uint8
const (
	StateStopped State = iota
	StateRunning
)

type Update

type Update struct {
	ID          string
	Name        string
	LastRenewed time.Time
	Error       error
	State       State
}

type UpdateFunc

type UpdateFunc func(Update)

Jump to

Keyboard shortcuts

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