mco_edge_open

Opens an edge database instance within a pre-allocated memory region.

For an overview, see the Edge Client page.

Prototype

    MCO_RET mco_edge_open(const char* db_name,
                          mco_dictionary_h dict,
                          void *memptr,
                          mco_size_t memsize,
                          mco_edge_params_t *params);
    

Arguments

db_name
Null-terminated string specifying the name of the edge database instance. Must be unique within the application.
dict
Dictionary handle generated by the mcocomp schema compiler for this edge application.
memptr
Pointer to a contiguous memory region where the edge database will be created. This region must remain valid for the lifetime of the database instance.
memsize
Size of the memory region pointed to by memptr, in bytes.
params
Pointer to an mco_edge_params_t structure containing initialization parameters. May be NULL to use default values. For a detailed description of the structure fields, see Edge Parameters.

Description

Opens an edge database instance within a pre-allocated memory region. The edge database header, internal structures, and RX/TX communication buffers are allocated from the specified memory region (memptr). The remaining space is used as a ring buffer for storing transaction data pending synchronization with the server.

The ring buffer size must be at least twice the size of the largest object in the schema to ensure proper operation. Since all classes in edge databases are fixed-size (a requirement of the edge client), this constraint is validated internally by mco_edge_open().

It is recommended to call mco_edge_start() explicitly before opening any edge databases to ensure proper runtime initialization, especially in multithreaded applications.

Return Codes

MCO_S_OK
Database instance opened successfully.
MCO_E_ILLEGAL_PARAM
One or more parameter values are invalid (e.g., NULL db_name, insufficient memsize, or invalid buffer sizes in params).
MCO_E_INSTANCE_DUPLICATE
A database instance with the specified db_name already exists.
MCO_E_INSTANCES_LIMIT
Maximum number of open database instances exceeded (compile-time limit).

Files

Header file:
mcoedge.h
Source file:
mcoedgedb.c
Library:
libmcoiotedge.a