Help us shape the future of Go! Take the 2026 Go Developer Survey

models

package
v0.38.3 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubscribeAction         = "subscribe"
	UnsubscribeAction       = "unsubscribe"
	ListSubscriptionsAction = "list_subscription"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountEvents

type AccountEvents map[string]models.Events

AccountEvents represents a mapping of account addresses to their associated events.

func (*AccountEvents) Build

func (a *AccountEvents) Build(accountEvents map[string]flow.EventsList)

Build creates AccountEvents instance by converting each flow.EventsList to the corresponding models.Events.

type AccountStatusesResponse

type AccountStatusesResponse struct {
	BlockID       string        `json:"block_id"`
	Height        string        `json:"height"`
	AccountEvents AccountEvents `json:"account_events"`
	MessageIndex  uint64        `json:"message_index"`
}

AccountStatusesResponse is the response message for 'events' topic.

func (*AccountStatusesResponse) Build

func (e *AccountStatusesResponse) Build(accountStatusesResponse *backend.AccountStatusesResponse, index uint64)

Build creates AccountStatusesResponse instance.

type Arguments

type Arguments map[string]interface{}

type BaseDataProvidersResponse

type BaseDataProvidersResponse struct {
	SubscriptionID string      `json:"subscription_id"` // Unique subscriptionID
	Topic          string      `json:"topic"`           // Topic of the subscription
	Payload        interface{} `json:"payload"`         // Payload that's being returned within a subscription.
}

BaseDataProvidersResponse represents a base structure for responses from subscriptions.

func (*BaseDataProvidersResponse) Build

func (b *BaseDataProvidersResponse) Build(subscriptionID string, topic string, payload interface{})

Build creates BaseDataProvidersResponse instance for consistent responses of the data providers.

type BaseMessageRequest

type BaseMessageRequest struct {
	// SubscriptionID is UUID generated by either client or server to uniquely identify subscription.
	// It is empty for 'list_subscription' action
	SubscriptionID string `json:"subscription_id,omitempty"`
	Action         string `json:"action"` // Action is an action to perform (e.g. 'subscribe' to some data)
}

BaseMessageRequest represents a base structure for incoming messages.

type BaseMessageResponse

type BaseMessageResponse struct {
	SubscriptionID string       `json:"subscription_id"` // SubscriptionID might be empty in case of error response
	Error          ErrorMessage `json:"error,omitempty"` // Error might be empty in case of OK response
	Action         string       `json:"action"`
}

BaseMessageResponse represents a base structure for outgoing messages.

type BlockDigest

type BlockDigest struct {
	BlockId   string    `json:"block_id"`
	Height    string    `json:"height"`
	Timestamp time.Time `json:"timestamp"`
}

BlockDigest is a lightweight block information model.

func (*BlockDigest) Build

func (b *BlockDigest) Build(block *flow.BlockDigest)

Build creates a BlockDigest instance with data from the provided flow.BlockDigest.

type BlockDigestMessageResponse

type BlockDigestMessageResponse struct {
	// The sealed or finalized block digest according to the block status
	// in the request.
	Block *BlockDigest `json:"block_digest"`
}

BlockDigestMessageResponse is the response message for 'block_digests' topic.

type BlockHeaderMessageResponse

type BlockHeaderMessageResponse struct {
	// The sealed or finalized block headers according to the block status
	// in the request.
	Header *models.BlockHeader `json:"header"`
}

BlockHeaderMessageResponse is the response message for 'block_headers' topic.

type BlockMessageResponse

type BlockMessageResponse struct {
	// The sealed or finalized blocks according to the block status
	// in the request.
	Block *models.Block `json:"block"`
}

BlockMessageResponse is the response message for 'blocks' topic.

type ErrorMessage

type ErrorMessage struct {
	Code    int    `json:"code"` // Code is an error code that categorizes an error
	Message string `json:"message"`
}

type EventResponse

type EventResponse struct {
	models.BlockEvents        // Embed BlockEvents struct to reuse its fields
	MessageIndex       uint64 `json:"message_index"`
}

EventResponse is the response message for 'events' topic.

func (*EventResponse) Build

func (e *EventResponse) Build(eventsResponse *backend.EventsResponse, index uint64)

Build creates EventResponse instance.

type ListSubscriptionsMessageRequest

type ListSubscriptionsMessageRequest struct {
	BaseMessageRequest
}

ListSubscriptionsMessageRequest represents a request to list active subscriptions.

type ListSubscriptionsMessageResponse

type ListSubscriptionsMessageResponse struct {
	// Subscription list might be empty in case of no active subscriptions
	Subscriptions []*SubscriptionEntry `json:"subscriptions"`
	Action        string               `json:"action"`
}

ListSubscriptionsMessageResponse is the structure used to respond to list_subscriptions requests. It contains a list of active subscriptions for the current WebSocket connection.

type SubscribeMessageRequest

type SubscribeMessageRequest struct {
	BaseMessageRequest
	Topic     string    `json:"topic"`     // Topic to subscribe to
	Arguments Arguments `json:"arguments"` // Additional arguments for subscription
}

SubscribeMessageRequest represents a request to subscribe to a topic.

type SubscribeMessageResponse

type SubscribeMessageResponse struct {
	BaseMessageResponse
}

SubscribeMessageResponse represents the response to a subscription request.

type SubscriptionEntry

type SubscriptionEntry struct {
	SubscriptionID string    `json:"subscription_id"` // ID is a client generated UUID for subscription
	Topic          string    `json:"topic"`           // Topic of the subscription
	Arguments      Arguments `json:"arguments"`
}

SubscriptionEntry represents an active subscription entry.

type TransactionStatusesResponse

type TransactionStatusesResponse struct {
	TransactionResult *commonmodels.TransactionResult `json:"transaction_result"`
	MessageIndex      uint64                          `json:"message_index"`
}

TransactionStatusesResponse is the response message for 'events' topic.

func (*TransactionStatusesResponse) Build

func (t *TransactionStatusesResponse) Build(
	linkGenerator commonmodels.LinkGenerator,
	txResult *access.TransactionResult,
	index uint64,
)

Build creates TransactionStatusesResponse instance.

type UnsubscribeMessageRequest

type UnsubscribeMessageRequest struct {
	// Note: subscription_id is mandatory for this request
	BaseMessageRequest
}

UnsubscribeMessageRequest represents a request to unsubscribe from a topic.

type UnsubscribeMessageResponse

type UnsubscribeMessageResponse struct {
	BaseMessageResponse
}

UnsubscribeMessageResponse represents the response to an unsubscription request.

Jump to

Keyboard shortcuts

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