Events

The events plugin carries temporary messages and request/response exchanges between the callers of one open database. Use it to tell a live consumer that facts changed, to wake a worker, or to exchange streaming results without writing a fact for each message. Enable it at open with plugins {events {}}. It has no settings. See plugin selection for the open options.

Follow Checkers with the events plugin for a runnable progression through pub/sub, request, pull, push and duplex.

Events are not database state. A publication or an exchange message never enters the store, and commits never publish an event. The plugin does not retry, acknowledge or replay a message. Record anything that must survive as facts first, then publish an event that tells consumers to read those facts. Only definitions of publication subjects and exchange routes are stored. Events travel inside the process through the C API and the bindings; they use no network.

Owners

A caller opens an event owner with open_owner. Subscriptions, worker registrations and exchange sides belong to the owner that created them. Only that owner may use or end them; another owner's id reports wrong_owner. close_owner ends everything the owner holds and cancels its exchanges: each other party reads a cancel notice. Closing the database closes every owner and interrupts waiting calls with closed.

Publish and subscribe

A publisher sends one native value to a literal subject with publish. A subject is a non-empty, slash-separated name with no empty segment, such as orders/created. Publishing needs no owner, and a publication with no matching subscriber succeeds.

An owner starts a subscription with subscribe. Its pattern is a regular expression that Stardust anchors to the complete subject. Thus orders/.* matches orders/created, while created does not.

The owner pulls events with receive, which waits up to maxWait. A subscription queues at most 1024 events or 8 MB, and queued bytes count against the database memory budget. When a queue is full, or the budget refuses a delivery, Stardust drops that delivery without delaying the publisher or other subscribers. The publisher learns the number of deliveries and drops from the result of publish. A subscription reports the deliveries it missed in the dropped member of the event it returns next. A publication holds at most 1 MB of data.

unsubscribe ends a subscription and drops its queued events.

Exchanges

An exchange connects one caller to one worker. A worker registers a mode and a subject pattern with register. A caller opens that mode on a literal subject with call. The registration with the lowest id among the matches serves the call, and a call with no matching worker reports no_worker.

ModeCaller sendsWorker sends
requestOne request, as data of the callOne response
pushA stream, then finishOne response, after the caller finished
pullOne request, as data of the callA stream, then finish
duplexA stream, then finishA stream, then finish

The worker takes the next exchange with accept, which returns the worker side's handle and, for request and pull, the request. Each side sends with send, tells the other party it sent everything with finish, and reads with read. read returns a message, a finish or a cancel notice. Finishing closes only the finishing side's sending direction, so it can still read.

cancel ends the exchange at once, and the other party reads cancel. Closing either owner cancels the exchange. Unregistering a worker cancels its exchanges that are still waiting for acceptance. Exchanges that the worker already accepted continue after unregistering. Each side queues at most 1024 messages or 8 MB against the memory budget; a send that does not fit reports delivery_failed and cancels the exchange, because dropping a message would corrupt it. A completed or cancelled exchange leaves its sides readable until their queues drain, then they disappear.

Definitions

A stored definition of the event type fixes the request and response of a route. Write it with patch_definition under the events kind at <mode>/<route>, for example request/orders/create. Its document holds a JSON Schema for each direction:

123 B
{request {type object required [customer] properties {customer {type string}}}
 response {type object required [accepted]}}

The first path segment is the mode, which fixes who may stream. Use {} for a direction that carries any value. A call with a definition checks its request, and every later message of the exchange against the schemas as they were when the call opened. A message that breaks its schema reports invalid_payload and leaves the exchange running. A route without a definition is unchecked. Definitions are ordinary stored definitions: history, backups and restores carry them. A database that stores an event definition refuses to open without the events plugin, so its contracts cannot be skipped. The SDK generation plugin renders typed publish, subscribe, caller and worker code for the stored routes in each language's output folder.

A publication definition lives at publish/<subject>, for example publish/orders/created. Its document is the payload schema:

62 B
type object
required [order]
properties {order {type integer}}

Each publication uses the subject's current schema before it changes any subscriber queue. Invalid data reports invalid_payload, including when there are no subscribers. Subjects without definitions remain unchecked. Generated publish and subscribe helpers bind the subject and payload type; subscriptions match the exact subject. Event results preserve empty objects and arrays inside payloads.

Runtime status

Call status to inspect these fields:

FieldContents
ownersOpen owners
subscriptionsOpen subscriptions
registrationsWorker registrations
rpcsLive exchanges
queuedItems waiting in all queues

Operations

OperationReturnsSummary
Events.Statusdocumentevents.status() returns the event runtime's owned status document.
Events.OpenOwnerdocumentevents.open_owner() opens an event owner and returns an owned document with its id.
Events.CloseOwnernoneevents.close_owner(owner) ends everything an owner holds and cancels its exchanges.
Events.Publishdocumentevents.publish(event) delivers one temporary message to every matching subscription and returns an owned count document.
Events.Subscribedocumentevents.subscribe(owner, pattern) starts a subscription of an owner and returns an owned document with its id.
Events.Receivedocumentevents.receive(options) returns the oldest queued event of a subscription as an owned document.
Events.Unsubscribenoneevents.unsubscribe(owner, subscription) ends a subscription and drops its queued events.
Events.Registerdocumentevents.register(owner, mode, pattern) registers an owner as a worker for exchanges and returns an owned document with the registration id.
Events.Unregisternoneevents.unregister(owner, registration) ends a worker registration.
Events.Acceptdocumentevents.accept(options) takes the oldest waiting exchange of a registration and returns an owned document describing it.
Events.Calldocumentevents.call(request) opens an exchange with the earliest matching worker and returns an owned document with the caller side's handle.
Events.Sendnoneevents.send(request) sends one message on an exchange side to the other party.
Events.Finishnoneevents.finish(owner, handle) ends the sending direction of an exchange side.
Events.Cancelnoneevents.cancel(owner, handle) cancels an exchange and drops the caller's side.
Events.Readdocumentevents.read(options) returns the oldest notice of an exchange side as an owned document.

Events.Status

go43 B
func (v Events) Status() (*Document, error)

Errors

StatusWhen
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed
StatusOutOfMemorynative memory is exhausted

Notes

The document counts owners, subscriptions, registrations, exchanges and queued items: see runtime status.

Examples

Count owners, subscriptions and queued items

go86 B
result, err := db.Events().Status()
if err != nil {
	return err
}
defer result.Close()
Result / 131 B
{:value {:owners        0
         :subscriptions 0
         :registrations 0
         :rpcs          0
         :queued        0}}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

Events.OpenOwner

go46 B
func (v Events) OpenOwner() (*Document, error)

Errors

StatusWhen
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed
StatusOutOfMemorynative memory is exhausted

Notes

Subscriptions, registrations and exchange sides belong to an owner. See owners.

Examples

Open an event owner

go89 B
result, err := db.Events().OpenOwner()
if err != nil {
	return err
}
defer result.Close()
Result / 19 B
{:value {:owner 1}}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

Events.CloseOwner

go45 B
func (v Events) CloseOwner(owner int64) error

Parameters

ParameterTypeOwnershipDefaultMeaning
ownerint64ValueRequiredThe owner that opened it, from open_owner.

Errors

StatusWhen
StatusInvalidArgumentthe request is not an object with only an integer owner
StatusNotFoundthe owner does not exist or ended
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed

Examples

Close an owner and everything it holds

go145 B
step1, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step1.Close()
if err := db.Events().CloseOwner(1); err != nil {
	return err
}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

Events.Publish

go59 B
func (v Events) Publish(event *Document) (*Document, error)

Parameters

ParameterTypeOwnershipDefaultMeaning
event*DocumentBorrowed for the callRequiredA borrowed object {subject data}. subject is a literal subject; data is any native value.

Errors

StatusWhen
StatusInvalidArgumentevent is not an object with exactly subject and data, the subject is malformed (code invalid_subject), or data exceeds 1 MB (code too_large)
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed
StatusOutOfMemorynative memory is exhausted

Notes

A publication is never stored or replayed. See publishing.

Examples

Publish a temporary message

go413 B
step1, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step1.Close()
step2, err := db.Events().Subscribe(1, "orders/.*")
if err != nil {
	return err
}
step2.Close()
doc3, err := stardust.Parse([]byte(`{subject orders/created data {order 42}}`), stardust.DUST)
if err != nil {
	return err
}
defer doc3.Close()
result, err := db.Events().Publish(doc3)
if err != nil {
	return err
}
defer result.Close()
Result / 45 B
{:value {:delivered 1
         :dropped   0}}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

Events.Subscribe

go73 B
func (v Events) Subscribe(owner int64, pattern string) (*Document, error)

Parameters

ParameterTypeOwnershipDefaultMeaning
ownerint64ValueRequiredThe owner that opened it, from open_owner.
patternstringValueRequiredA regular expression for the complete subject.

Errors

StatusWhen
StatusInvalidArgumentthe request is malformed, or the pattern is empty or not a valid regular expression (code invalid_pattern)
StatusNotFoundthe owner does not exist
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed
StatusOutOfMemorynative memory is exhausted

Notes

A pattern is a regular expression anchored to the complete subject. See subscriptions.

Examples

Subscribe to every order subject

go185 B
step1, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step1.Close()
result, err := db.Events().Subscribe(1, "orders/.*")
if err != nil {
	return err
}
defer result.Close()
Result / 26 B
{:value {:subscription 2}}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

Events.Receive

go61 B
func (v Events) Receive(options *Document) (*Document, error)

Parameters

ParameterTypeOwnershipDefaultMeaning
options*DocumentBorrowed for the callAbsent selects operation defaultsA borrowed object {owner subscription maxWait}. maxWait is an optional nonnegative native duration.

Errors

StatusWhen
StatusInvalidArgumentoptions is not an object with owner and subscription (integers) and optionally a valid maxWait, or the subscription belongs to another owner (code wrong_owner)
StatusNotFoundthe owner or the subscription does not exist
StatusTimeoutmaxWait passed before an event arrived
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed
StatusOutOfMemorynative memory is exhausted

Notes

receive waits up to maxWait. Without it the call checks once and reports timeout when no event is queued.

Examples

Receive the oldest queued event

go645 B
step1, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step1.Close()
step2, err := db.Events().Subscribe(1, "orders/.*")
if err != nil {
	return err
}
step2.Close()
doc3, err := stardust.Parse([]byte(`{subject orders/created data {order 42}}`), stardust.DUST)
if err != nil {
	return err
}
defer doc3.Close()
step3, err := db.Events().Publish(doc3)
if err != nil {
	return err
}
step3.Close()
doc4, err := stardust.Parse([]byte(`{owner 1 subscription 2 maxWait {#dur PT1S}}`), stardust.DUST)
if err != nil {
	return err
}
defer doc4.Close()
result, err := db.Events().Receive(doc4)
if err != nil {
	return err
}
defer result.Close()
Result / 110 B
{:value {:subject  "orders/created"
         :sequence 1
         :dropped  0
         :data     {:order 42}}}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

Events.Unsubscribe

go66 B
func (v Events) Unsubscribe(owner int64, subscription int64) error

Parameters

ParameterTypeOwnershipDefaultMeaning
ownerint64ValueRequiredThe owner that opened it, from open_owner.
subscriptionint64ValueRequiredThe id subscribe returned.

Errors

StatusWhen
StatusInvalidArgumentthe request is malformed, or the subscription belongs to another owner (code wrong_owner)
StatusNotFoundthe owner or the subscription does not exist or ended
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed

Examples

End a subscription

go245 B
step1, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step1.Close()
step2, err := db.Events().Subscribe(1, "orders/.*")
if err != nil {
	return err
}
step2.Close()
if err := db.Events().Unsubscribe(1, 2); err != nil {
	return err
}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

Events.Register

go85 B
func (v Events) Register(owner int64, mode string, pattern string) (*Document, error)

Parameters

ParameterTypeOwnershipDefaultMeaning
ownerint64ValueRequiredThe owner that opened it, from open_owner.
modestringValueRequiredrequest, push, pull or duplex.
patternstringValueRequiredA regular expression for the complete subject.

Errors

StatusWhen
StatusInvalidArgumentthe request is malformed, the mode is unknown (code invalid_mode) or the pattern is empty or invalid (code invalid_pattern)
StatusNotFoundthe owner does not exist
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed
StatusOutOfMemorynative memory is exhausted

Notes

The earliest matching registration serves each call. See exchanges.

Examples

Register an owner as a worker

go195 B
step1, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step1.Close()
result, err := db.Events().Register(1, "request", "orders/.*")
if err != nil {
	return err
}
defer result.Close()
Result / 26 B
{:value {:registration 2}}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

Events.Unregister

go65 B
func (v Events) Unregister(owner int64, registration int64) error

Parameters

ParameterTypeOwnershipDefaultMeaning
ownerint64ValueRequiredThe owner that opened it, from open_owner.
registrationint64ValueRequiredThe id register returned.

Errors

StatusWhen
StatusInvalidArgumentthe request is malformed, or the registration belongs to another owner (code wrong_owner)
StatusNotFoundthe owner or the registration does not exist
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed

Examples

End a worker registration

go254 B
step1, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step1.Close()
step2, err := db.Events().Register(1, "request", "orders/.*")
if err != nil {
	return err
}
step2.Close()
if err := db.Events().Unregister(1, 2); err != nil {
	return err
}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

Events.Accept

go60 B
func (v Events) Accept(options *Document) (*Document, error)

Parameters

ParameterTypeOwnershipDefaultMeaning
options*DocumentBorrowed for the callAbsent selects operation defaultsA borrowed object {owner registration maxWait}. maxWait is an optional nonnegative native duration.

Errors

StatusWhen
StatusInvalidArgumentoptions is not an object with owner and registration (integers) and optionally a valid maxWait, or the registration belongs to another owner (code wrong_owner)
StatusNotFoundthe owner or the registration does not exist
StatusTimeoutmaxWait passed before an exchange arrived
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed
StatusOutOfMemorynative memory is exhausted

Notes

accept waits up to maxWait. The result carries the worker side's handle: see exchanges.

Examples

Take the oldest waiting exchange as the worker

go757 B
step1, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step1.Close()
step2, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step2.Close()
step3, err := db.Events().Register(2, "request", "orders/.*")
if err != nil {
	return err
}
step3.Close()
doc4, err := stardust.Parse([]byte(`{owner 1 mode request subject orders/create data {customer Ada}}`), stardust.DUST)
if err != nil {
	return err
}
defer doc4.Close()
step4, err := db.Events().Call(doc4)
if err != nil {
	return err
}
step4.Close()
doc5, err := stardust.Parse([]byte(`{owner 2 registration 3 maxWait {#dur PT1S}}`), stardust.DUST)
if err != nil {
	return err
}
defer doc5.Close()
result, err := db.Events().Accept(doc5)
if err != nil {
	return err
}
defer result.Close()
Result / 139 B
{:value {:handle  6
         :rpc     4
         :mode    "request"
         :subject "orders/create"
         :data    {:customer "Ada"}}}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

Events.Call

go58 B
func (v Events) Call(request *Document) (*Document, error)

Parameters

ParameterTypeOwnershipDefaultMeaning
request*DocumentBorrowed for the callRequiredA borrowed object {owner mode subject data}.

Errors

StatusWhen
StatusInvalidArgumentrequest is malformed, the mode or subject is invalid (codes invalid_mode and invalid_subject), data is missing for request or pull, present for push or duplex, or exceeds 1 MB, or data does not match the stored request schema (code invalid_payload)
StatusNotFoundthe owner does not exist, or no registered worker matches (code no_worker)
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed
StatusOutOfMemorynative memory is exhausted

Notes

A stored definition for the route checks every message. See exchanges and definitions.

Examples

Open a request exchange with a worker

go526 B
step1, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step1.Close()
step2, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step2.Close()
step3, err := db.Events().Register(2, "request", "orders/.*")
if err != nil {
	return err
}
step3.Close()
doc4, err := stardust.Parse([]byte(`{owner 1 mode request subject orders/create data {customer Ada}}`), stardust.DUST)
if err != nil {
	return err
}
defer doc4.Close()
result, err := db.Events().Call(doc4)
if err != nil {
	return err
}
defer result.Close()
Result / 39 B
{:value {:handle 5
         :rpc    4}}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

Events.Send

go45 B
func (v Events) Send(request *Document) error

Parameters

ParameterTypeOwnershipDefaultMeaning
request*DocumentBorrowed for the callRequiredA borrowed object {owner handle data}.

Errors

StatusWhen
StatusInvalidArgumentrequest is malformed, the side may not send now (code wrong_direction), the handle belongs to another owner (code wrong_owner), or data does not match its schema (code invalid_payload)
StatusNotFoundthe owner or the side does not exist, or the exchange ended and the side drained
StatusConflictthe side already finished (code already_finished), or the other party's queue is full (code delivery_failed)
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed

Notes

A message is checked against the stored schemas of its route. See exchanges.

Examples

Answer a request as the worker

go933 B
step1, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step1.Close()
step2, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step2.Close()
step3, err := db.Events().Register(2, "request", "orders/.*")
if err != nil {
	return err
}
step3.Close()
doc4, err := stardust.Parse([]byte(`{owner 1 mode request subject orders/create data {customer Ada}}`), stardust.DUST)
if err != nil {
	return err
}
defer doc4.Close()
step4, err := db.Events().Call(doc4)
if err != nil {
	return err
}
step4.Close()
doc5, err := stardust.Parse([]byte(`{owner 2 registration 3}`), stardust.DUST)
if err != nil {
	return err
}
defer doc5.Close()
step5, err := db.Events().Accept(doc5)
if err != nil {
	return err
}
step5.Close()
doc6, err := stardust.Parse([]byte(`{owner 2 handle 6 data {accepted true}}`), stardust.DUST)
if err != nil {
	return err
}
defer doc6.Close()
if err := db.Events().Send(doc6); err != nil {
	return err
}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

Events.Finish

go55 B
func (v Events) Finish(owner int64, handle int64) error

Parameters

ParameterTypeOwnershipDefaultMeaning
ownerint64ValueRequiredThe owner that opened it, from open_owner.
handleint64ValueRequiredThe side handle: from call for the caller, from accept for the worker.

Errors

StatusWhen
StatusInvalidArgumentthe request is malformed, the side cannot finish in this mode (code wrong_direction), or the handle belongs to another owner (code wrong_owner)
StatusNotFoundthe owner or the side does not exist
StatusConflictthe side already finished (code already_finished), or the other party's queue is full (code delivery_failed)
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed

Examples

Finish the caller's stream

go552 B
step1, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step1.Close()
step2, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step2.Close()
step3, err := db.Events().Register(2, "push", "uploads/.*")
if err != nil {
	return err
}
step3.Close()
doc4, err := stardust.Parse([]byte(`{owner 1 mode push subject uploads/a}`), stardust.DUST)
if err != nil {
	return err
}
defer doc4.Close()
step4, err := db.Events().Call(doc4)
if err != nil {
	return err
}
step4.Close()
if err := db.Events().Finish(1, 5); err != nil {
	return err
}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

Events.Cancel

go55 B
func (v Events) Cancel(owner int64, handle int64) error

Parameters

ParameterTypeOwnershipDefaultMeaning
ownerint64ValueRequiredThe owner that opened it, from open_owner.
handleint64ValueRequiredThe side handle: from call for the caller, from accept for the worker.

Errors

StatusWhen
StatusInvalidArgumentthe request is malformed, or the handle belongs to another owner (code wrong_owner)
StatusNotFoundthe owner or the side does not exist
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed

Examples

Cancel an exchange

go552 B
step1, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step1.Close()
step2, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step2.Close()
step3, err := db.Events().Register(2, "push", "uploads/.*")
if err != nil {
	return err
}
step3.Close()
doc4, err := stardust.Parse([]byte(`{owner 1 mode push subject uploads/a}`), stardust.DUST)
if err != nil {
	return err
}
defer doc4.Close()
step4, err := db.Events().Call(doc4)
if err != nil {
	return err
}
step4.Close()
if err := db.Events().Cancel(1, 5); err != nil {
	return err
}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release

Events.Read

go58 B
func (v Events) Read(options *Document) (*Document, error)

Parameters

ParameterTypeOwnershipDefaultMeaning
options*DocumentBorrowed for the callAbsent selects operation defaultsA borrowed object {owner handle maxWait}. maxWait is an optional nonnegative native duration.

Errors

StatusWhen
StatusInvalidArgumentoptions is not an object with owner and handle (integers) and optionally a valid maxWait, or the handle belongs to another owner (code wrong_owner)
StatusNotFoundthe owner or the side does not exist, or it drained after the exchange ended
StatusTimeoutmaxWait passed before a notice arrived
StatusUnavailablethe database does not enable the events plugin
StatusClosedthe database is closed
StatusOutOfMemorynative memory is exhausted

Notes

A message, the other party's finish or a cancel arrives as kind message, finish or cancel.

Examples

Read the worker's response

go1.2 kB
step1, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step1.Close()
step2, err := db.Events().OpenOwner()
if err != nil {
	return err
}
step2.Close()
step3, err := db.Events().Register(2, "request", "orders/.*")
if err != nil {
	return err
}
step3.Close()
doc4, err := stardust.Parse([]byte(`{owner 1 mode request subject orders/create data {customer Ada}}`), stardust.DUST)
if err != nil {
	return err
}
defer doc4.Close()
step4, err := db.Events().Call(doc4)
if err != nil {
	return err
}
step4.Close()
doc5, err := stardust.Parse([]byte(`{owner 2 registration 3}`), stardust.DUST)
if err != nil {
	return err
}
defer doc5.Close()
step5, err := db.Events().Accept(doc5)
if err != nil {
	return err
}
step5.Close()
doc6, err := stardust.Parse([]byte(`{owner 2 handle 6 data {accepted true}}`), stardust.DUST)
if err != nil {
	return err
}
defer doc6.Close()
if err := db.Events().Send(doc6); err != nil {
	return err
}
doc7, err := stardust.Parse([]byte(`{owner 1 handle 5 maxWait {#dur PT1S}}`), stardust.DUST)
if err != nil {
	return err
}
defer doc7.Close()
result, err := db.Events().Read(doc7)
if err != nil {
	return err
}
defer result.Close()
Result / 58 B
{:value {:kind "message"
         :data {:accepted true}}}

C exports: stardust_db_plugin_call, stardust_result_take_document, stardust_result_error, stardust_result_release