Versions in this module Expand all Collapse all v0 v0.2.0 Sep 29, 2026 Changes in this version + var ErrAlreadyStarted = errors.New("nt4: already started") + var ErrClosed = errors.New("nt4: closed") + var ErrForeignHandle = errors.New("nt4: foreign handle") + var ErrIncompatibleOptions = errors.New("nt4: incompatible options") + var ErrInvalidHandle = errors.New("nt4: invalid handle") + var ErrInvalidType = errors.New("nt4: invalid type") + var ErrInvalidValue = errors.New("nt4: invalid value") + var ErrProtocol = errors.New("nt4: protocol error") + var ErrQueueFull = errors.New("nt4: queue full") + var ErrSubscriptionOverflow = errors.New("nt4: subscription overflow") + var ErrTimestampUnrepresentable = errors.New("nt4: timestamp unrepresentable") + var ErrTypeConflict = errors.New("nt4: type conflict") + func CloneValue(v any) any + func JSONSize(m map[string]any, limits JSONLimits) (int, error) + func OwnJSON(input map[string]any, limits JSONLimits) (map[string]any, int, error) + func OwnValue(typeName string, input any, maxBytes int) (any, int, error) + func TypeID(name string) (int, error) + func ValidatePatterns(patterns []string, prefix bool, maxNameBytes int) error + func ValidatePublisherOptions(o PublisherOptions, c ClientOptions) error + func ValidateTopicName(name string, maxBytes int) error + func ValueSize(v any) int type Client + func (c *Client) Close() error + func (c *Client) GetBooleanArray(name string, timeout time.Duration) ([]bool, bool) + func (c *Client) GetDoubleArray(name string, timeout time.Duration) ([]float64, bool) + func (c *Client) GetFloat(name string, timeout time.Duration) (float32, bool) + func (c *Client) GetIntArray(name string, timeout time.Duration) ([]int64, bool) + func (c *Client) GetRaw(name string, timeout time.Duration) ([]byte, bool) + func (c *Client) GetStringArray(name string, timeout time.Duration) ([]string, bool) + func (c *Client) Latest(name string) (Sample, bool) + func (c *Client) PublishFloat(name string, value float32) (*Publisher, error) + func (c *Client) PublishFloatArray(name string, value []float32) (*Publisher, error) + func (c *Client) PublishTopic(name, typeStr string, props map[string]any) (*Publisher, error) + func (c *Client) Start(ctx context.Context) error + func (c *Client) StateChanges() <-chan Status + func (c *Client) Status() Status + func (c *Client) SubscribeWithOptions(patterns []string, o SubscribeOptions) (*Subscription, error) + func (c *Client) Topic(name string) (TopicSnapshot, bool) + func (c *Client) Topics() []TopicSnapshot + func (c *Client) WaitConnected(ctx context.Context) error + func (c *Client) WaitForValue(ctx context.Context, name string) (Sample, error) + func (c *Client) WaitReady(ctx context.Context) error + type ClientBuilder struct + func NewClientBuilder() *ClientBuilder + func (b *ClientBuilder) Build() (*Client, error) + func (b *ClientBuilder) BuildAndStart(ctx context.Context) (*Client, error) + func (b *ClientBuilder) DialTimeout(d time.Duration) *ClientBuilder + func (b *ClientBuilder) EndpointURL(url string) *ClientBuilder + func (b *ClientBuilder) Identity(id string) *ClientBuilder + func (b *ClientBuilder) Keepalive(interval time.Duration) *ClientBuilder + func (b *ClientBuilder) Logger(l Logger) *ClientBuilder + func (b *ClientBuilder) Name(name string) *ClientBuilder + func (b *ClientBuilder) OnConnect(fn func()) *ClientBuilder + func (b *ClientBuilder) OnDisconnect(fn func()) *ClientBuilder + func (b *ClientBuilder) OnTopicAnnounce(fn func(topic *Topic)) *ClientBuilder + func (b *ClientBuilder) OnTopicUnannounce(fn func(topic *Topic)) *ClientBuilder + func (b *ClientBuilder) Options(opts ClientOptions) *ClientBuilder + func (b *ClientBuilder) Port(port int) *ClientBuilder + func (b *ClientBuilder) ReadTimeout(d time.Duration) *ClientBuilder + func (b *ClientBuilder) ReconnectInterval(d time.Duration) *ClientBuilder + func (b *ClientBuilder) Retry(min, max time.Duration) *ClientBuilder + func (b *ClientBuilder) Server(address string) *ClientBuilder + func (b *ClientBuilder) Team(teamNumber int) *ClientBuilder + func (b *ClientBuilder) WriteTimeout(d time.Duration) *ClientBuilder type ClientOptions + ClientName string + CommandCapacity int + CommandMaxBytes int + DialTimeout time.Duration + EndpointURL string + InboundCapacity int + InboundMaxBytes int + KeepaliveInterval time.Duration + MaxBinaryBytes int + MaxJSONContainerItems int + MaxJSONDepth int + MaxNameBytes int + MaxPublishers int + MaxSubscriptions int + MaxTextBytes int + MaxTopics int + ReadTimeout time.Duration + RetainedMaxBytes int + RetryMax time.Duration + RetryMin time.Duration + TotalOfflineCapacity int + TotalOfflineMaxBytes int + WriteTimeout time.Duration + WriterCapacity int + WriterMaxBytes int + func NormalizeClientOptions(o ClientOptions) (ClientOptions, error) + type DeliveryMode uint8 + const DeliveryAll + const DeliveryLatest + type Event struct + Ack bool + Epoch uint64 + Kind EventKind + ReceivedAt time.Time + Sample Sample + Topic TopicSnapshot + func (e Event) Clone() Event + type EventKind uint8 + const Announced + const LocalInvalidated + const PropertiesChanged + const ServerUnannounced + const ValueReceived + type JSONLimits struct + MaxBytes int + MaxContainerItems int + MaxDepth int + MaxNameBytes int + type LifecycleState uint8 + const StateBackoff + const StateClosed + const StateClosing + const StateDialing + const StateIdle + const StateOnlineReady + const StateOnlineUnsynchronized + type Publisher struct + func (p *Publisher) Close() error + func (p *Publisher) DiscardPending() error + func (p *Publisher) Err() error + func (p *Publisher) Errors() <-chan error + func (p *Publisher) Set(v any) error + func (p *Publisher) SetAt(at time.Time, v any) error + func (p *Publisher) SetContext(ctx context.Context, v any) error + func (p *Publisher) SetDefault(v any) error + func (p *Publisher) TrySet(v any) error + type PublisherOptions struct + OfflineQueueCapacity int + OfflineQueueMaxBytes int + type Sample struct + Epoch uint64 + ReceivedAt time.Time + Stale bool + Timestamp int64 + Value any + func (s Sample) Clone() Sample + type Status struct + ClockOffset time.Duration + ClockValid bool + CommandBytes uint64 + CommandItems uint64 + Dropped uint64 + Epoch uint64 + InboundBytes uint64 + InboundItems uint64 + LastError error + LastLoss error + OfflineBytes uint64 + OfflineItems uint64 + Protocol string + RTT time.Duration + Ready bool + Rejected uint64 + RetainedBytes uint64 + State LifecycleState + StateChangesDropped uint64 + Uncertain uint64 + WriterBytes uint64 + WriterItems uint64 type Subscription + func (s *Subscription) Close() error + func (s *Subscription) Dropped() uint64 + func (s *Subscription) Err() <-chan error + func (s *Subscription) Events() <-chan Event + type SubscriptionOptions struct + All bool + BufferCapacity int + BufferMaxBytes int + Mode DeliveryMode + Periodic time.Duration + Prefix bool + TopicsOnly bool + func NormalizeSubscriptionOptions(o SubscriptionOptions) (SubscriptionOptions, error) type Topic + Publisher *Publisher + type TopicSnapshot struct + Epoch uint64 + HasID bool + ID int32 + Name string + Properties map[string]any + Stale bool + Type string + func (t TopicSnapshot) Clone() TopicSnapshot v0.1.1 Nov 20, 2025 Changes in this version + const DataTypeBinary + const DataTypeBoolean + const DataTypeBooleanArray + const DataTypeDouble + const DataTypeDoubleArray + const DataTypeFloat + const DataTypeFloatArray + const DataTypeInt + const DataTypeIntArray + const DataTypeString + const DataTypeStringArray + const DefaultPort + const TypeBoolean + const TypeBooleanArray + const TypeDouble + const TypeDoubleArray + const TypeFloat + const TypeFloatArray + const TypeInt + const TypeIntArray + const TypeJSON + const TypeMsgpack + const TypeProtobuf + const TypeRaw + const TypeString + const TypeStringArray + var ErrAlreadyConnected = errors.New("already connected to server") + var ErrInvalidOptions = errors.New("invalid client options") + var ErrInvalidTopicID = errors.New("invalid topic ID") + var ErrMessageDecoding = errors.New("message decoding failed") + var ErrMessageEncoding = errors.New("message encoding failed") + var ErrNotConnected = errors.New("not connected to server") + var ErrTopicNotFound = errors.New("topic not found") + func TeamNumberToAddress(teamNumber int) string + func TypeIDToString(typeID int) string + func TypeStringToID(typeStr string) int + type Client struct + func NewClient(options ClientOptions) *Client + func (c *Client) Connect() error + func (c *Client) ConnectWithRetry(ctx context.Context) error + func (c *Client) Disconnect() + func (c *Client) GetBoolean(name string, timeout time.Duration) (bool, bool) + func (c *Client) GetDouble(name string, timeout time.Duration) (float64, bool) + func (c *Client) GetInt(name string, timeout time.Duration) (int64, bool) + func (c *Client) GetLastRTT() int64 + func (c *Client) GetServerTimeOffset() int64 + func (c *Client) GetString(name string, timeout time.Duration) (string, bool) + func (c *Client) GetTopic(name string) *Topic + func (c *Client) GetTopics() []*Topic + func (c *Client) IsConnected() bool + func (c *Client) Publish(name string, typeStr string, properties map[string]any) *Topic + func (c *Client) PublishBoolean(name string, value bool) *Topic + func (c *Client) PublishBooleanArray(name string, value []bool) *Topic + func (c *Client) PublishDouble(name string, value float64) *Topic + func (c *Client) PublishDoubleArray(name string, value []float64) *Topic + func (c *Client) PublishInt(name string, value int64) *Topic + func (c *Client) PublishIntArray(name string, value []int64) *Topic + func (c *Client) PublishRaw(name string, value []byte) *Topic + func (c *Client) PublishString(name string, value string) *Topic + func (c *Client) PublishStringArray(name string, value []string) *Topic + func (c *Client) SetProperties(name string, properties map[string]any) + func (c *Client) SetValue(topic *Topic, value any) + func (c *Client) Subscribe(topics []string, options *SubscribeOptions) *Subscription + func (c *Client) SubscribeAndRetrieve(topic string, timeout time.Duration) any + func (c *Client) SubscribeWithPrefix(prefix string, callback func(topic *Topic, timestamp int64, value any)) *Subscription + func (c *Client) Unpublish(topic *Topic) + func (c *Client) Unsubscribe(sub *Subscription) + func (c *Client) WaitForConnection(ctx context.Context) error + type ClientOptions struct + Identity string + Logger Logger + OnConnect func() + OnDisconnect func() + OnTopicAnnounce func(topic *Topic) + OnTopicUnannounce func(topic *Topic) + Port int + ReconnectInterval time.Duration + ServerAddress string + func DefaultClientOptions(serverAddress string) ClientOptions + type ConnectionError struct + Address string + Err error + Port int + func (e *ConnectionError) Error() string + func (e *ConnectionError) Unwrap() error + type DefaultLogger struct + func NewDefaultLogger(level LogLevel) *DefaultLogger + func (l *DefaultLogger) Debug(msg string, keysAndValues ...any) + func (l *DefaultLogger) Error(msg string, keysAndValues ...any) + func (l *DefaultLogger) Info(msg string, keysAndValues ...any) + func (l *DefaultLogger) Warn(msg string, keysAndValues ...any) + type LogLevel int + const LogLevelDebug + const LogLevelError + const LogLevelInfo + const LogLevelSilent + const LogLevelWarn + func (l LogLevel) String() string + type Logger interface + Debug func(msg string, keysAndValues ...any) + Error func(msg string, keysAndValues ...any) + Info func(msg string, keysAndValues ...any) + Warn func(msg string, keysAndValues ...any) + func NewSilentLogger() Logger + type ProtocolError struct + Err error + Message string + func (e *ProtocolError) Error() string + func (e *ProtocolError) Unwrap() error + type SilentLogger struct + func (l *SilentLogger) Debug(msg string, keysAndValues ...any) + func (l *SilentLogger) Error(msg string, keysAndValues ...any) + func (l *SilentLogger) Info(msg string, keysAndValues ...any) + func (l *SilentLogger) Warn(msg string, keysAndValues ...any) + type SubscribeOptions struct + All bool + Periodic float64 + Prefix bool + TopicsOnly bool + type Subscription struct + Options SubscribeOptions + Topics []string + UID int32 + func (sub *Subscription) CloseUpdates() + func (sub *Subscription) GetCallback() func(topic *Topic, timestamp int64, value any) + func (sub *Subscription) InitUpdates(bufferSize int) + func (sub *Subscription) SendUpdate(update TopicUpdate) bool + func (sub *Subscription) SetCallback(callback func(topic *Topic, timestamp int64, value any)) + func (sub *Subscription) Updates() <-chan TopicUpdate + type TimeoutError struct + Err error + Operation string + func (e *TimeoutError) Error() string + func (e *TimeoutError) Unwrap() error + type Topic struct + ID int32 + Name string + Properties map[string]any + PubUID int32 + Type string + TypeID int + func (t *Topic) UpdateProperties(props map[string]any) + type TopicUpdate struct + Timestamp int64 + Topic *Topic + Value any + type ValidationError struct + Field string + Message string + Value any + func (e *ValidationError) Error() string v0.1.0 Nov 20, 2025