session

package
v0.0.0-...-1a2806f Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const MaxIDSequence = 10

MaxIDSequence max srcid sequence

Variables

This section is empty.

Functions

func RemoveSession

func RemoveSession(sess *Session)

RemoveSession remove from pool

Types

type IDStack

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

IDStack store srcIDs,max

func (*IDStack) Pop

func (s *IDStack) Pop() (ret int32)

Pop id from stack

func (*IDStack) Push

func (s *IDStack) Push(v int32)

Push id to stack

func (*IDStack) Reset

func (s *IDStack) Reset()

Reset data

type Session

type Session struct {
	IP        net.IP
	Port      string
	SrcID     int32 //module id
	MQ        queue.Queue
	SessionID string
	Done      chan *Session

	Request  proto.Message
	Response proto.Message
	Die      chan struct{} // session die signal, will be triggered by others
	// contains filtered or unexported fields
}

Session connection identify

func CreateSession

func CreateSession(srcID int32, host string, port string) *Session

CreateSession from session pool

func GetSession

func GetSession(sessionID string) *Session

GetSession get Session By sessionID

func (*Session) NotifyDone

func (s *Session) NotifyDone()

NotifyDone tigger done notify

func (*Session) PopSrcID

func (s *Session) PopSrcID() int32

PopSrcID get last srcID

func (*Session) PushSrcID

func (s *Session) PushSrcID(srcID int32)

PushSrcID add SrcID to message src seq

func (*Session) Reset

func (s *Session) Reset()

Reset session set to default value

type SessionPool

type SessionPool struct {
	Pool *sync.Pool
	Objs sync.Map
}

SessionPool mamager session objests

func GS

func GS() *SessionPool

GS session instance

func NewSessionPool

func NewSessionPool() *SessionPool

NewSessionPool new session pool

func (*SessionPool) Alloc

func (p *SessionPool) Alloc(srcID int32, host string, port string) *Session

Alloc borrow session from pool

func (*SessionPool) Free

func (p *SessionPool) Free(sess *Session)

Free retrun session to pool

Jump to

Keyboard shortcuts

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