model

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package model includes models definition

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentTimeMicroseconds

func CurrentTimeMicroseconds() int64

Types

type Message

type Message struct {
	SessionID  string `json:"session_id,omitempty"`
	MessageID  string `json:"message,omitempty"`
	CreateTime int64  `json:"create_time,omitempty"`

	Content       string   `json:"content,omitempty"`
	Metadata      Metadata `json:"metadata,omitempty"`
	SearchContent string   `json:"search_content,omitempty"`
}

func NewMessage

func NewMessage(sessionID, messageID string) *Message

NewMessage creates a message with current time (microseconds)

func NewMessageFull

func NewMessageFull(
	sessionID,
	messageID string,
	createTime int64,
	content string,
	metadata Metadata,
) *Message

func NewMessageWithTime

func NewMessageWithTime(sessionID, messageID string, createTime int64) *Message

func (*Message) Clone

func (m *Message) Clone() *Message

Clone copy constructor

func (*Message) SetContent

func (m *Message) SetContent(content string) *Message

func (*Message) SetCreateTime

func (m *Message) SetCreateTime(t int64) *Message

-------------------- fluent setters (chainable) --------------------

func (*Message) SetMetadata

func (m *Message) SetMetadata(metadata Metadata) *Message

func (*Message) SetSearchContent added in v1.0.3

func (m *Message) SetSearchContent(content string) *Message

type MetaType

type MetaType int
const (
	STRING MetaType = iota
	INTEGER
	BOOLEAN
	DOUBLE
	BINARY
)

type Metadata

type Metadata map[string]any

func MetadataFrom

func MetadataFrom(key, value string) (Metadata, error)

func MetadataFromMap

func MetadataFromMap(m map[string]any) (Metadata, error)

func NewMetadata

func NewMetadata() Metadata

func (Metadata) Copy

func (m Metadata) Copy() Metadata

func (Metadata) Get

func (m Metadata) Get(key string) (any, bool)

func (Metadata) GetBool

func (m Metadata) GetBool(key string) *bool

func (Metadata) GetBytes

func (m Metadata) GetBytes(key string) ([]byte, error)

func (Metadata) GetFloat64

func (m Metadata) GetFloat64(key string) *float64

func (Metadata) GetInt

func (m Metadata) GetInt(key string) *int

func (Metadata) GetInt64

func (m Metadata) GetInt64(key string) *int64

func (Metadata) GetString

func (m Metadata) GetString(key string) *string

func (Metadata) HasKey

func (m Metadata) HasKey(key string) bool

func (Metadata) Merge

func (m Metadata) Merge(another Metadata) (Metadata, error)

func (Metadata) Put

func (m Metadata) Put(key string, value any) error

func (Metadata) PutBool

func (m Metadata) PutBool(key string, value bool) error

func (Metadata) PutBytes

func (m Metadata) PutBytes(key string, value []byte) error

func (Metadata) PutFloat64

func (m Metadata) PutFloat64(key string, value float64) error

func (Metadata) PutInt

func (m Metadata) PutInt(key string, value int) error

func (Metadata) PutInt64

func (m Metadata) PutInt64(key string, value int64) error

func (Metadata) PutString

func (m Metadata) PutString(key, value string) error

func (Metadata) Remove

func (m Metadata) Remove(key string) Metadata

func (Metadata) Size

func (m Metadata) Size() int

func (Metadata) ToMap

func (m Metadata) ToMap() map[string]any

type Option

type Option func(*Options)

func WithMessageSearchIndexName added in v1.0.3

func WithMessageSearchIndexName(name string) Option

func WithMessageSecondaryIndexName

func WithMessageSecondaryIndexName(name string) Option

func WithMessageTableName

func WithMessageTableName(name string) Option

func WithSessionSearchIndexName added in v1.0.3

func WithSessionSearchIndexName(name string) Option

func WithSessionSecondaryIndexName

func WithSessionSecondaryIndexName(name string) Option

func WithSessionTableName

func WithSessionTableName(name string) Option

type Options

type Options struct {
	SessionTableName          string
	MessageTableName          string
	SessionSecondaryIndexName string
	SessionSearchIndexName    string
	MessageSecondaryIndexName string
	MessageSearchIndexName    string
}

type Response

type Response[T any] struct {
	// Total total amount of search results
	Total int64 `json:"total,omitempty"`
	// Hits search results
	Hits []T `json:"hits,omitempty"`
	// NextStartPrimaryKey indicates the starting position for the next page.
	NextStartPrimaryKey *tablestore.PrimaryKey `json:"next_start_primary_key,omitempty"`
	// NextToken indicates the starting position for the next page (for search)
	NextToken []byte `json:"next_token,omitempty"`
}

type Session

type Session struct {
	UserID    string `json:"user_id,omitempty"`
	SessionID string `json:"session_id,omitempty"`

	UpdateTime    int64    `json:"update_time,omitempty"`
	Metadata      Metadata `json:"metadata,omitempty"`
	SearchContent string   `json:"search_content,omitempty"`
}

func NewSession

func NewSession(userID, sessionID string) *Session

NewSession creates a new session with current update time

func NewSessionFull

func NewSessionFull(
	userID,
	sessionID string,
	updateTime int64,
	metadata Metadata,
) *Session

func NewSessionWithTime

func NewSessionWithTime(userID, sessionID string, updateTime int64) *Session

func (*Session) Clone

func (s *Session) Clone() *Session

Clone copy constructor

func (*Session) RefreshUpdateTime

func (s *Session) RefreshUpdateTime()

RefreshUpdateTime updates the update time to now (microseconds)

func (*Session) SetMetadata

func (s *Session) SetMetadata(metadata Metadata) *Session

func (*Session) SetSearchContent added in v1.0.3

func (s *Session) SetSearchContent(content string) *Session

func (*Session) SetUpdateTime

func (s *Session) SetUpdateTime(t int64) *Session

-------------------- fluent setters --------------------

Jump to

Keyboard shortcuts

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