observation

package
v3.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ObservationSequenceTimeout = 128 * time.Second

ObservationSequenceTimeout defines how long is sequence number is valid. https://tools.ietf.org/html/rfc7641#section-3.4

Variables

This section is empty.

Functions

func AuthenticatedSequenceNumber added in v3.9.0

func AuthenticatedSequenceNumber(ctx context.Context) (uint64, bool)

AuthenticatedSequenceNumber returns the authenticated sequence number attached to a message.

func CopyAuthenticatedSequenceNumber added in v3.9.0

func CopyAuthenticatedSequenceNumber(ctx context.Context, r *pool.Message)

CopyAuthenticatedSequenceNumber copies authenticated ordering metadata onto a message without replacing the message's context.

func SetAuthenticatedSequenceNumber added in v3.9.0

func SetAuthenticatedSequenceNumber(r *pool.Message, sequence uint64)

SetAuthenticatedSequenceNumber marks a notification with its authenticated, non-wrapping sequence number for ordering by the observation handler.

func ValidSequenceNumber

func ValidSequenceNumber(oldValue, newValue uint32, lastEventOccurs time.Time, now time.Time) bool

ValidSequenceNumber implements conditions in https://tools.ietf.org/html/rfc7641#section-3.4

Types

type Client

type Client interface {
	Context() context.Context
	WriteMessage(req *pool.Message) error
	ReleaseMessage(msg *pool.Message)
	AcquireMessage(ctx context.Context) *pool.Message
}

type DoFunc

type DoFunc = func(req *pool.Message) (*pool.Message, error)

type Handler

type Handler[C Client] struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler[C Client](cc C, next HandlerFunc[C], do DoFunc) *Handler[C]

func (*Handler[C]) ForgetObservation added in v3.9.0

func (h *Handler[C]) ForgetObservation(token message.Token) bool

ForgetObservation removes a local observation without sending a cancellation request.

func (*Handler[C]) GetObservation

func (h *Handler[C]) GetObservation(key uint64) (*Observation[C], bool)

func (*Handler[C]) GetObservationRequest

func (h *Handler[C]) GetObservationRequest(token message.Token) (*pool.Message, bool)

GetObservationRequest returns observation request for token

func (*Handler[C]) Handle

func (h *Handler[C]) Handle(w *responsewriter.ResponseWriter[C], r *pool.Message)

func (*Handler[C]) HandleNotification added in v3.7.0

func (h *Handler[C]) HandleNotification(r *pool.Message) bool

HandleNotification delivers a complete notification only while its observation exists.

func (*Handler[C]) HandleNotificationFrom added in v3.9.2

func (h *Handler[C]) HandleNotificationFrom(r *pool.Message, remoteAddr net.Addr) bool

HandleNotificationFrom delivers a notification only when the observation has a known peer endpoint that matches remoteAddr. An unknown endpoint or nil remoteAddr fails closed. Use HandleNotification when endpoint validation is not available for the transport.

func (*Handler[C]) HandleNotificationOrNext added in v3.9.2

func (h *Handler[C]) HandleNotificationOrNext(w *responsewriter.ResponseWriter[C], r *pool.Message) bool

HandleNotificationOrNext delivers a notification to its active observation, or forwards the message to the next handler. It reports whether an observation handled the message.

func (*Handler[C]) NewObservation

func (h *Handler[C]) NewObservation(req *pool.Message, observeFunc func(req *pool.Message)) (*Observation[C], error)

func (*Handler[C]) SetDebug added in v3.9.2

func (h *Handler[C]) SetDebug(debug func(format string, args ...any))

SetDebug enables protocol diagnostics for observation matching.

type HandlerFunc

type HandlerFunc[C Client] func(*responsewriter.ResponseWriter[C], *pool.Message)

The HandlerFunc type is an adapter to allow the use of ordinary functions as COAP handlers.

type Observation

type Observation[C Client] struct {
	// contains filtered or unexported fields
}

Observation represents subscription to resource on the server

func (*Observation[C]) Cancel

func (o *Observation[C]) Cancel(ctx context.Context, opts ...message.Option) error

Cancel remove observation from server. For recreate observation use Observe.

func (*Observation[C]) Canceled

func (o *Observation[C]) Canceled() bool

func (*Observation[C]) Request

func (o *Observation[C]) Request() message.Message

Jump to

Keyboard shortcuts

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