sessionutil

package
v0.10.3-0...-cb65423 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Licensed to the LF AI & Data foundation under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// DefaultServiceRoot default root path used in kv by Session
	DefaultServiceRoot = "session/"
	// DefaultIDKey default id key for Session
	DefaultIDKey         = "id"
	SupportedLabelPrefix = "MILVUS_SERVER_LABEL_"
)

Variables

This section is empty.

Functions

func GetServerInfoFilePath

func GetServerInfoFilePath(pid int) string

GetServerInfoFilePath get server info file path, eg: /tmp/milvus/server_id_123456789 Notes: this method will not support Windows OS return file path

func GetServerLabelsFromEnv

func GetServerLabelsFromEnv(role string) map[string]string

func GetSessionPrefixByRole

func GetSessionPrefixByRole(role string) string

GetSessionPrefixByRole get session prefix by role

func GetSessions

func GetSessions(pid int) []string

func RemoveServerInfoFile

func RemoveServerInfoFile(pid int)

func SaveServerInfo

func SaveServerInfo(role string, serverID int64)

Types

type IndexEngineVersion

type IndexEngineVersion struct {
	MinimalIndexVersion int32 `json:"MinimalIndexVersion,omitempty"`
	CurrentIndexVersion int32 `json:"CurrentIndexVersion,omitempty"`
}

type MockSession

type MockSession struct {
	mock.Mock
}

MockSession is an autogenerated mock type for the SessionInterface type

func NewMockSession

func NewMockSession(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockSession

NewMockSession creates a new instance of MockSession. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockSession) Disconnected

func (_m *MockSession) Disconnected() bool

Disconnected provides a mock function with given fields:

func (*MockSession) EXPECT

func (_m *MockSession) EXPECT() *MockSession_Expecter

func (*MockSession) ForceActiveStandby

func (_m *MockSession) ForceActiveStandby(activateFunc func() error) error

ForceActiveStandby provides a mock function with given fields: activateFunc

func (*MockSession) GetAddress

func (_m *MockSession) GetAddress() string

GetAddress provides a mock function with given fields:

func (*MockSession) GetServerID

func (_m *MockSession) GetServerID() int64

GetServerID provides a mock function with given fields:

func (*MockSession) GetSessions

func (_m *MockSession) GetSessions(prefix string) (map[string]*Session, int64, error)

GetSessions provides a mock function with given fields: prefix

func (*MockSession) GetSessionsWithVersionRange

func (_m *MockSession) GetSessionsWithVersionRange(prefix string, r semver.Range) (map[string]*Session, int64, error)

GetSessionsWithVersionRange provides a mock function with given fields: prefix, r

func (*MockSession) GoingStop

func (_m *MockSession) GoingStop() error

GoingStop provides a mock function with given fields:

func (*MockSession) Init

func (_m *MockSession) Init(serverName string, address string, exclusive bool, triggerKill bool)

Init provides a mock function with given fields: serverName, address, exclusive, triggerKill

func (*MockSession) IsTriggerKill

func (_m *MockSession) IsTriggerKill() bool

IsTriggerKill provides a mock function with given fields:

func (*MockSession) LivenessCheck

func (_m *MockSession) LivenessCheck(ctx context.Context, callback func())

LivenessCheck provides a mock function with given fields: ctx, callback

func (*MockSession) MarshalJSON

func (_m *MockSession) MarshalJSON() ([]byte, error)

MarshalJSON provides a mock function with given fields:

func (*MockSession) ProcessActiveStandBy

func (_m *MockSession) ProcessActiveStandBy(activateFunc func() error) error

ProcessActiveStandBy provides a mock function with given fields: activateFunc

func (*MockSession) Register

func (_m *MockSession) Register()

Register provides a mock function with given fields:

func (*MockSession) Registered

func (_m *MockSession) Registered() bool

Registered provides a mock function with given fields:

func (*MockSession) Revoke

func (_m *MockSession) Revoke(timeout time.Duration)

Revoke provides a mock function with given fields: timeout

func (*MockSession) SetDisconnected

func (_m *MockSession) SetDisconnected(b bool)

SetDisconnected provides a mock function with given fields: b

func (*MockSession) SetEnableActiveStandBy

func (_m *MockSession) SetEnableActiveStandBy(enable bool)

SetEnableActiveStandBy provides a mock function with given fields: enable

func (*MockSession) Stop

func (_m *MockSession) Stop()

Stop provides a mock function with given fields:

func (*MockSession) String

func (_m *MockSession) String() string

String provides a mock function with given fields:

func (*MockSession) UnmarshalJSON

func (_m *MockSession) UnmarshalJSON(data []byte) error

UnmarshalJSON provides a mock function with given fields: data

func (*MockSession) UpdateRegistered

func (_m *MockSession) UpdateRegistered(b bool)

UpdateRegistered provides a mock function with given fields: b

func (*MockSession) WatchServices

func (_m *MockSession) WatchServices(prefix string, revision int64, rewatch Rewatch) <-chan *SessionEvent

WatchServices provides a mock function with given fields: prefix, revision, rewatch

func (*MockSession) WatchServicesWithVersionRange

func (_m *MockSession) WatchServicesWithVersionRange(prefix string, r semver.Range, revision int64, rewatch Rewatch) <-chan *SessionEvent

WatchServicesWithVersionRange provides a mock function with given fields: prefix, r, revision, rewatch

type MockSession_Disconnected_Call

type MockSession_Disconnected_Call struct {
	*mock.Call
}

MockSession_Disconnected_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Disconnected'

func (*MockSession_Disconnected_Call) Return

func (*MockSession_Disconnected_Call) Run

func (*MockSession_Disconnected_Call) RunAndReturn

type MockSession_Expecter

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

func (*MockSession_Expecter) Disconnected

Disconnected is a helper method to define mock.On call

func (*MockSession_Expecter) ForceActiveStandby

func (_e *MockSession_Expecter) ForceActiveStandby(activateFunc interface{}) *MockSession_ForceActiveStandby_Call

ForceActiveStandby is a helper method to define mock.On call

  • activateFunc func() error

func (*MockSession_Expecter) GetAddress

GetAddress is a helper method to define mock.On call

func (*MockSession_Expecter) GetServerID

GetServerID is a helper method to define mock.On call

func (*MockSession_Expecter) GetSessions

func (_e *MockSession_Expecter) GetSessions(prefix interface{}) *MockSession_GetSessions_Call

GetSessions is a helper method to define mock.On call

  • prefix string

func (*MockSession_Expecter) GetSessionsWithVersionRange

func (_e *MockSession_Expecter) GetSessionsWithVersionRange(prefix interface{}, r interface{}) *MockSession_GetSessionsWithVersionRange_Call

GetSessionsWithVersionRange is a helper method to define mock.On call

  • prefix string
  • r semver.Range

func (*MockSession_Expecter) GoingStop

GoingStop is a helper method to define mock.On call

func (*MockSession_Expecter) Init

func (_e *MockSession_Expecter) Init(serverName interface{}, address interface{}, exclusive interface{}, triggerKill interface{}) *MockSession_Init_Call

Init is a helper method to define mock.On call

  • serverName string
  • address string
  • exclusive bool
  • triggerKill bool

func (*MockSession_Expecter) IsTriggerKill

IsTriggerKill is a helper method to define mock.On call

func (*MockSession_Expecter) LivenessCheck

func (_e *MockSession_Expecter) LivenessCheck(ctx interface{}, callback interface{}) *MockSession_LivenessCheck_Call

LivenessCheck is a helper method to define mock.On call

  • ctx context.Context
  • callback func()

func (*MockSession_Expecter) MarshalJSON

MarshalJSON is a helper method to define mock.On call

func (*MockSession_Expecter) ProcessActiveStandBy

func (_e *MockSession_Expecter) ProcessActiveStandBy(activateFunc interface{}) *MockSession_ProcessActiveStandBy_Call

ProcessActiveStandBy is a helper method to define mock.On call

  • activateFunc func() error

func (*MockSession_Expecter) Register

Register is a helper method to define mock.On call

func (*MockSession_Expecter) Registered

Registered is a helper method to define mock.On call

func (*MockSession_Expecter) Revoke

func (_e *MockSession_Expecter) Revoke(timeout interface{}) *MockSession_Revoke_Call

Revoke is a helper method to define mock.On call

  • timeout time.Duration

func (*MockSession_Expecter) SetDisconnected

func (_e *MockSession_Expecter) SetDisconnected(b interface{}) *MockSession_SetDisconnected_Call

SetDisconnected is a helper method to define mock.On call

  • b bool

func (*MockSession_Expecter) SetEnableActiveStandBy

func (_e *MockSession_Expecter) SetEnableActiveStandBy(enable interface{}) *MockSession_SetEnableActiveStandBy_Call

SetEnableActiveStandBy is a helper method to define mock.On call

  • enable bool

func (*MockSession_Expecter) Stop

Stop is a helper method to define mock.On call

func (*MockSession_Expecter) String

String is a helper method to define mock.On call

func (*MockSession_Expecter) UnmarshalJSON

func (_e *MockSession_Expecter) UnmarshalJSON(data interface{}) *MockSession_UnmarshalJSON_Call

UnmarshalJSON is a helper method to define mock.On call

  • data []byte

func (*MockSession_Expecter) UpdateRegistered

func (_e *MockSession_Expecter) UpdateRegistered(b interface{}) *MockSession_UpdateRegistered_Call

UpdateRegistered is a helper method to define mock.On call

  • b bool

func (*MockSession_Expecter) WatchServices

func (_e *MockSession_Expecter) WatchServices(prefix interface{}, revision interface{}, rewatch interface{}) *MockSession_WatchServices_Call

WatchServices is a helper method to define mock.On call

  • prefix string
  • revision int64
  • rewatch Rewatch

func (*MockSession_Expecter) WatchServicesWithVersionRange

func (_e *MockSession_Expecter) WatchServicesWithVersionRange(prefix interface{}, r interface{}, revision interface{}, rewatch interface{}) *MockSession_WatchServicesWithVersionRange_Call

WatchServicesWithVersionRange is a helper method to define mock.On call

  • prefix string
  • r semver.Range
  • revision int64
  • rewatch Rewatch

type MockSession_ForceActiveStandby_Call

type MockSession_ForceActiveStandby_Call struct {
	*mock.Call
}

MockSession_ForceActiveStandby_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ForceActiveStandby'

func (*MockSession_ForceActiveStandby_Call) Return

func (*MockSession_ForceActiveStandby_Call) Run

func (_c *MockSession_ForceActiveStandby_Call) Run(run func(activateFunc func() error)) *MockSession_ForceActiveStandby_Call

func (*MockSession_ForceActiveStandby_Call) RunAndReturn

type MockSession_GetAddress_Call

type MockSession_GetAddress_Call struct {
	*mock.Call
}

MockSession_GetAddress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAddress'

func (*MockSession_GetAddress_Call) Return

func (*MockSession_GetAddress_Call) Run

func (*MockSession_GetAddress_Call) RunAndReturn

func (_c *MockSession_GetAddress_Call) RunAndReturn(run func() string) *MockSession_GetAddress_Call

type MockSession_GetServerID_Call

type MockSession_GetServerID_Call struct {
	*mock.Call
}

MockSession_GetServerID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetServerID'

func (*MockSession_GetServerID_Call) Return

func (*MockSession_GetServerID_Call) Run

func (*MockSession_GetServerID_Call) RunAndReturn

func (_c *MockSession_GetServerID_Call) RunAndReturn(run func() int64) *MockSession_GetServerID_Call

type MockSession_GetSessionsWithVersionRange_Call

type MockSession_GetSessionsWithVersionRange_Call struct {
	*mock.Call
}

MockSession_GetSessionsWithVersionRange_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSessionsWithVersionRange'

func (*MockSession_GetSessionsWithVersionRange_Call) Return

func (*MockSession_GetSessionsWithVersionRange_Call) Run

func (*MockSession_GetSessionsWithVersionRange_Call) RunAndReturn

type MockSession_GetSessions_Call

type MockSession_GetSessions_Call struct {
	*mock.Call
}

MockSession_GetSessions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSessions'

func (*MockSession_GetSessions_Call) Return

func (*MockSession_GetSessions_Call) Run

func (*MockSession_GetSessions_Call) RunAndReturn

type MockSession_GoingStop_Call

type MockSession_GoingStop_Call struct {
	*mock.Call
}

MockSession_GoingStop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GoingStop'

func (*MockSession_GoingStop_Call) Return

func (*MockSession_GoingStop_Call) Run

func (*MockSession_GoingStop_Call) RunAndReturn

func (_c *MockSession_GoingStop_Call) RunAndReturn(run func() error) *MockSession_GoingStop_Call

type MockSession_Init_Call

type MockSession_Init_Call struct {
	*mock.Call
}

MockSession_Init_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Init'

func (*MockSession_Init_Call) Return

func (*MockSession_Init_Call) Run

func (_c *MockSession_Init_Call) Run(run func(serverName string, address string, exclusive bool, triggerKill bool)) *MockSession_Init_Call

func (*MockSession_Init_Call) RunAndReturn

func (_c *MockSession_Init_Call) RunAndReturn(run func(string, string, bool, bool)) *MockSession_Init_Call

type MockSession_IsTriggerKill_Call

type MockSession_IsTriggerKill_Call struct {
	*mock.Call
}

MockSession_IsTriggerKill_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsTriggerKill'

func (*MockSession_IsTriggerKill_Call) Return

func (*MockSession_IsTriggerKill_Call) Run

func (*MockSession_IsTriggerKill_Call) RunAndReturn

type MockSession_LivenessCheck_Call

type MockSession_LivenessCheck_Call struct {
	*mock.Call
}

MockSession_LivenessCheck_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LivenessCheck'

func (*MockSession_LivenessCheck_Call) Return

func (*MockSession_LivenessCheck_Call) Run

func (_c *MockSession_LivenessCheck_Call) Run(run func(ctx context.Context, callback func())) *MockSession_LivenessCheck_Call

func (*MockSession_LivenessCheck_Call) RunAndReturn

type MockSession_MarshalJSON_Call

type MockSession_MarshalJSON_Call struct {
	*mock.Call
}

MockSession_MarshalJSON_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MarshalJSON'

func (*MockSession_MarshalJSON_Call) Return

func (*MockSession_MarshalJSON_Call) Run

func (*MockSession_MarshalJSON_Call) RunAndReturn

func (_c *MockSession_MarshalJSON_Call) RunAndReturn(run func() ([]byte, error)) *MockSession_MarshalJSON_Call

type MockSession_ProcessActiveStandBy_Call

type MockSession_ProcessActiveStandBy_Call struct {
	*mock.Call
}

MockSession_ProcessActiveStandBy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProcessActiveStandBy'

func (*MockSession_ProcessActiveStandBy_Call) Return

func (*MockSession_ProcessActiveStandBy_Call) Run

func (*MockSession_ProcessActiveStandBy_Call) RunAndReturn

type MockSession_Register_Call

type MockSession_Register_Call struct {
	*mock.Call
}

MockSession_Register_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Register'

func (*MockSession_Register_Call) Return

func (*MockSession_Register_Call) Run

func (*MockSession_Register_Call) RunAndReturn

func (_c *MockSession_Register_Call) RunAndReturn(run func()) *MockSession_Register_Call

type MockSession_Registered_Call

type MockSession_Registered_Call struct {
	*mock.Call
}

MockSession_Registered_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Registered'

func (*MockSession_Registered_Call) Return

func (*MockSession_Registered_Call) Run

func (*MockSession_Registered_Call) RunAndReturn

func (_c *MockSession_Registered_Call) RunAndReturn(run func() bool) *MockSession_Registered_Call

type MockSession_Revoke_Call

type MockSession_Revoke_Call struct {
	*mock.Call
}

MockSession_Revoke_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Revoke'

func (*MockSession_Revoke_Call) Return

func (*MockSession_Revoke_Call) Run

func (_c *MockSession_Revoke_Call) Run(run func(timeout time.Duration)) *MockSession_Revoke_Call

func (*MockSession_Revoke_Call) RunAndReturn

func (_c *MockSession_Revoke_Call) RunAndReturn(run func(time.Duration)) *MockSession_Revoke_Call

type MockSession_SetDisconnected_Call

type MockSession_SetDisconnected_Call struct {
	*mock.Call
}

MockSession_SetDisconnected_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetDisconnected'

func (*MockSession_SetDisconnected_Call) Return

func (*MockSession_SetDisconnected_Call) Run

func (*MockSession_SetDisconnected_Call) RunAndReturn

type MockSession_SetEnableActiveStandBy_Call

type MockSession_SetEnableActiveStandBy_Call struct {
	*mock.Call
}

MockSession_SetEnableActiveStandBy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetEnableActiveStandBy'

func (*MockSession_SetEnableActiveStandBy_Call) Return

func (*MockSession_SetEnableActiveStandBy_Call) Run

func (*MockSession_SetEnableActiveStandBy_Call) RunAndReturn

type MockSession_Stop_Call

type MockSession_Stop_Call struct {
	*mock.Call
}

MockSession_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop'

func (*MockSession_Stop_Call) Return

func (*MockSession_Stop_Call) Run

func (_c *MockSession_Stop_Call) Run(run func()) *MockSession_Stop_Call

func (*MockSession_Stop_Call) RunAndReturn

func (_c *MockSession_Stop_Call) RunAndReturn(run func()) *MockSession_Stop_Call

type MockSession_String_Call

type MockSession_String_Call struct {
	*mock.Call
}

MockSession_String_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'String'

func (*MockSession_String_Call) Return

func (*MockSession_String_Call) Run

func (_c *MockSession_String_Call) Run(run func()) *MockSession_String_Call

func (*MockSession_String_Call) RunAndReturn

func (_c *MockSession_String_Call) RunAndReturn(run func() string) *MockSession_String_Call

type MockSession_UnmarshalJSON_Call

type MockSession_UnmarshalJSON_Call struct {
	*mock.Call
}

MockSession_UnmarshalJSON_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UnmarshalJSON'

func (*MockSession_UnmarshalJSON_Call) Return

func (*MockSession_UnmarshalJSON_Call) Run

func (*MockSession_UnmarshalJSON_Call) RunAndReturn

type MockSession_UpdateRegistered_Call

type MockSession_UpdateRegistered_Call struct {
	*mock.Call
}

MockSession_UpdateRegistered_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateRegistered'

func (*MockSession_UpdateRegistered_Call) Return

func (*MockSession_UpdateRegistered_Call) Run

func (*MockSession_UpdateRegistered_Call) RunAndReturn

type MockSession_WatchServicesWithVersionRange_Call

type MockSession_WatchServicesWithVersionRange_Call struct {
	*mock.Call
}

MockSession_WatchServicesWithVersionRange_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WatchServicesWithVersionRange'

func (*MockSession_WatchServicesWithVersionRange_Call) Return

func (*MockSession_WatchServicesWithVersionRange_Call) Run

func (*MockSession_WatchServicesWithVersionRange_Call) RunAndReturn

type MockSession_WatchServices_Call

type MockSession_WatchServices_Call struct {
	*mock.Call
}

MockSession_WatchServices_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WatchServices'

func (*MockSession_WatchServices_Call) Return

func (*MockSession_WatchServices_Call) Run

func (_c *MockSession_WatchServices_Call) Run(run func(prefix string, revision int64, rewatch Rewatch)) *MockSession_WatchServices_Call

func (*MockSession_WatchServices_Call) RunAndReturn

type Rewatch

type Rewatch func(sessions map[string]*Session) error

Rewatch defines the behavior outer session watch handles ErrCompacted it should process the current full list of session and returns err if meta error or anything else goes wrong

type Session

type Session struct {
	SessionRaw

	Version semver.Version `json:"Version,omitempty"`
	// contains filtered or unexported fields
}

Session is a struct to store service's session, including ServerID, ServerName, Address. Exclusive indicates that this server can only start one.

func NewSession

func NewSession(ctx context.Context, opts ...SessionOption) *Session

Create a new Session object. Will use global etcd client

func NewSessionWithEtcd

func NewSessionWithEtcd(ctx context.Context, metaRoot string, client *clientv3.Client, opts ...SessionOption) *Session

NewSessionWithEtcd is a helper to build a Session object. ServerID, ServerName, Address, Exclusive will be assigned after Init(). metaRoot is a path in etcd to save session information. etcdEndpoints is to init etcdCli when NewSession

func (*Session) Disconnected

func (s *Session) Disconnected() bool

func (*Session) ForceActiveStandby

func (s *Session) ForceActiveStandby(activateFunc func() error) error

func (*Session) GetSessions

func (s *Session) GetSessions(prefix string) (map[string]*Session, int64, error)

GetSessions will get all sessions registered in etcd. Revision is returned for WatchServices to prevent key events from being missed.

func (*Session) GetSessionsWithVersionRange

func (s *Session) GetSessionsWithVersionRange(prefix string, r semver.Range) (map[string]*Session, int64, error)

GetSessionsWithVersionRange will get all sessions with provided prefix and version range in etcd. Revision is returned for WatchServices to prevent missing events.

func (*Session) GoingStop

func (s *Session) GoingStop() error

func (*Session) Init

func (s *Session) Init(serverName, address string, exclusive bool, triggerKill bool)

Init will initialize base struct of the Session, including ServerName, ServerID, Address, Exclusive. ServerID is obtained in getServerID.

func (*Session) LivenessCheck

func (s *Session) LivenessCheck(ctx context.Context, callback func())

LivenessCheck performs liveness check with provided context and channel ctx controls the liveness check loop ch is the liveness signal channel, ch is closed only when the session is expired callback must be called before liveness check exit, to close the session's owner component

func (*Session) MarshalJSON

func (s *Session) MarshalJSON() ([]byte, error)

MarshalJSON marshals session to bytes.

func (*Session) ProcessActiveStandBy

func (s *Session) ProcessActiveStandBy(activateFunc func() error) error

ProcessActiveStandBy is used by coordinators to do active-standby mechanism. coordinator enabled active-standby will first call Register and then call ProcessActiveStandBy. steps: 1, Enter STANDBY mode 2, Try to register to active key. 3, If 2. return true, this service becomes ACTIVE. Exit STANDBY mode. 4, If 2. return false, which means an ACTIVE service already exist.

Start watching the active key. Whenever active key disappears, STANDBY node will go backup to 2.

activateFunc is the function to re-active the service.

func (*Session) Register

func (s *Session) Register()

Register will process keepAliveResponse to keep alive with etcd.

func (*Session) Registered

func (s *Session) Registered() bool

Registered check if session was registered into etcd.

func (*Session) Revoke

func (s *Session) Revoke(timeout time.Duration)

Revoke revokes the internal LeaseID for the session key

func (*Session) SetDisconnected

func (s *Session) SetDisconnected(b bool)

func (*Session) SetEnableActiveStandBy

func (s *Session) SetEnableActiveStandBy(enable bool)

func (*Session) Stop

func (s *Session) Stop()

func (*Session) String

func (s *Session) String() string

String makes Session struct able to be logged by zap

func (*Session) UnmarshalJSON

func (s *Session) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal bytes to Session.

func (*Session) UpdateRegistered

func (s *Session) UpdateRegistered(b bool)

UpdateRegistered update the state of registered.

func (*Session) WatchServices

func (s *Session) WatchServices(prefix string, revision int64, rewatch Rewatch) (eventChannel <-chan *SessionEvent)

WatchServices watches the service's up and down in etcd, and sends event to eventChannel. prefix is a parameter to know which service to watch and can be obtained in typeutil.type.go. revision is a etcd reversion to prevent missing key events and can be obtained in GetSessions. If a server up, an event will be add to channel with eventType SessionAddType. If a server down, an event will be add to channel with eventType SessionDelType.

func (*Session) WatchServicesWithVersionRange

func (s *Session) WatchServicesWithVersionRange(prefix string, r semver.Range, revision int64, rewatch Rewatch) (eventChannel <-chan *SessionEvent)

WatchServicesWithVersionRange watches the service's up and down in etcd, and sends event to event Channel. Acts like WatchServices but with extra version range check. prefix is a parameter to know which service to watch and can be obtained in type util.type.go. revision is a etcd reversion to prevent missing key events and can be obtained in GetSessions. If a server up, an event will be add to channel with eventType SessionAddType. If a server down, an event will be add to channel with eventType SessionDelType.

type SessionEvent

type SessionEvent struct {
	EventType SessionEventType
	Session   *Session
}

SessionEvent indicates the changes of other servers. if a server is up, EventType is SessAddEvent. if a server is down, EventType is SessDelEvent. Session Saves the changed server's information.

type SessionEventType

type SessionEventType int

SessionEventType session event type

const (
	// SessionNoneEvent place holder for zero value
	SessionNoneEvent SessionEventType = iota
	// SessionAddEvent event type for a new Session Added
	SessionAddEvent
	// SessionDelEvent event type for a Session deleted
	SessionDelEvent
	// SessionUpdateEvent event type for a Session stopping
	SessionUpdateEvent
)

func (SessionEventType) String

func (t SessionEventType) String() string

type SessionInterface

type SessionInterface interface {
	UnmarshalJSON(data []byte) error
	MarshalJSON() ([]byte, error)

	Init(serverName, address string, exclusive bool, triggerKill bool)
	String() string
	Register()

	GetSessions(prefix string) (map[string]*Session, int64, error)
	GetSessionsWithVersionRange(prefix string, r semver.Range) (map[string]*Session, int64, error)

	GoingStop() error
	WatchServices(prefix string, revision int64, rewatch Rewatch) (eventChannel <-chan *SessionEvent)
	WatchServicesWithVersionRange(prefix string, r semver.Range, revision int64, rewatch Rewatch) (eventChannel <-chan *SessionEvent)
	LivenessCheck(ctx context.Context, callback func())
	Stop()
	Revoke(timeout time.Duration)
	UpdateRegistered(b bool)
	Registered() bool
	SetDisconnected(b bool)
	Disconnected() bool
	SetEnableActiveStandBy(enable bool)
	ProcessActiveStandBy(activateFunc func() error) error
	ForceActiveStandby(activateFunc func() error) error

	GetAddress() string
	GetServerID() int64
	IsTriggerKill() bool
}

type SessionOption

type SessionOption func(session *Session)

func WithEnableDisk

func WithEnableDisk(enableDisk bool) SessionOption

func WithIndexEngineVersion

func WithIndexEngineVersion(minimal, current int32) SessionOption

WithIndexEngineVersion should be only used by querynode.

func WithResueNodeID

func WithResueNodeID(b bool) SessionOption

func WithRetryTimes

func WithRetryTimes(n int64) SessionOption

func WithTTL

func WithTTL(ttl int64) SessionOption

type SessionRaw

type SessionRaw struct {
	ServerID           int64  `json:"ServerID,omitempty"`
	ServerName         string `json:"ServerName,omitempty"`
	Address            string `json:"Address,omitempty"`
	Exclusive          bool   `json:"Exclusive,omitempty"`
	Stopping           bool   `json:"Stopping,omitempty"`
	TriggerKill        bool
	Version            string             `json:"Version"`
	IndexEngineVersion IndexEngineVersion `json:"IndexEngineVersion,omitempty"`
	LeaseID            *clientv3.LeaseID  `json:"LeaseID,omitempty"`

	HostName     string            `json:"HostName,omitempty"`
	EnableDisk   bool              `json:"EnableDisk,omitempty"`
	ServerLabels map[string]string `json:"ServerLabels,omitempty"`
}

SessionRaw the persistent part of Session.

func (*SessionRaw) GetAddress

func (s *SessionRaw) GetAddress() string

func (*SessionRaw) GetServerID

func (s *SessionRaw) GetServerID() int64

func (*SessionRaw) GetServerLabel

func (s *SessionRaw) GetServerLabel() map[string]string

func (*SessionRaw) IsTriggerKill

func (s *SessionRaw) IsTriggerKill() bool

Jump to

Keyboard shortcuts

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