session

package
v0.0.0-...-be0919c Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorInvalidProposal is validation error then invalid proposal requested for session creation
	ErrorInvalidProposal = errors.New("proposal does not exist")
)

Functions

func NewDialogHandler

func NewDialogHandler(sessionManagerFactory ManagerFactory) *handler

NewDialogHandler constructs handler which gets all incoming dialogs and starts handling them

func NewManager

func NewManager(
	currentProposal discovery_dto.ServiceProposal,
	idGenerator IDGenerator,
	configProvider ConfigProvider,
	saveCallback SaveCallback,
	promiseProcessor PromiseProcessor,
) *manager

NewManager returns new session manager

func RequestSessionCreate

func RequestSessionCreate(sender communication.Sender, proposalID int, sessionPtr *Session) error

RequestSessionCreate requests session creation and returns session DTO

Types

type ConfigProvider

type ConfigProvider func() (ServiceConfiguration, error)

ConfigProvider provides session config for remote client

type CreateRequest

type CreateRequest struct {
	ProposalId int `json:"proposal_id"`
}

CreateRequest structure represents message from service consumer to initiate session for given proposal id

type CreateResponse

type CreateResponse struct {
	Success bool       `json:"success"`
	Message string     `json:"message"`
	Session SessionDto `json:"session"`
}

CreateResponse structure represents service provider response to given session request from consumer

type ID

type ID string

ID represents session id type

func GenerateUUID

func GenerateUUID() (ID, error)

GenerateUUID method returns ID based on random UUID, or error if we fail to generate one

type IDGenerator

type IDGenerator func() (ID, error)

IDGenerator defines method for session id generation

type Manager

type Manager interface {
	Create(consumerID identity.Identity, proposalID int) (Session, error)
}

Manager defines methods for session management

type ManagerFactory

type ManagerFactory func(dialog communication.Dialog) Manager

ManagerFactory initiates session manager instance during runtime

type PromiseProcessor

type PromiseProcessor interface {
	Start(discovery_dto.ServiceProposal) error
	Stop() error
}

PromiseProcessor processes promises at provider side. Provider checks promises from consumer and signs them also. Provider clears promises from consumer.

type SaveCallback

type SaveCallback func(Session)

SaveCallback stores newly started sessions

type ServiceConfiguration

type ServiceConfiguration interface{}

ServiceConfiguration defines service configuration from underlying transport mechanism to be passed to remote party should be serializable to json format

type Session

type Session struct {
	ID         ID
	Config     ServiceConfiguration
	ConsumerID identity.Identity
}

Session structure holds all required information about current session between service consumer and provider

type SessionDto

type SessionDto struct {
	ID     ID              `json:"id"`
	Config json.RawMessage `json:"config"`
}

SessionDto structure represents session information data within session creation response (session id and configuration options for underlaying service type)

type StorageMemory

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

StorageMemory maintains a map of session id -> session

func NewStorageMemory

func NewStorageMemory() *StorageMemory

NewStorageMemory initiates new session storage

func (*StorageMemory) Add

func (storage *StorageMemory) Add(sessionInstance Session)

Add puts given session to storage. Multiple sessions per peerID is possible in case different services are used

func (*StorageMemory) Find

func (storage *StorageMemory) Find(id ID) (Session, bool)

Find returns underlying session instance

func (*StorageMemory) Remove

func (storage *StorageMemory) Remove(id ID)

Remove removes given session from underlying storage

Jump to

Keyboard shortcuts

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