InstanceCreator::SetUrn

Contents

InstanceCreator::SetUrn#

inline InstanceCreator<Creator> &YR::internal::InstanceCreator::SetUrn(const std::string &urn)#

Set the function URN for the instance creation.

// Example: Setting the URN for an instance
int main(void) {
    YR::Config conf;
    YR::Init(conf);

    auto cppCls = YR::CppInstanceClass::FactoryCreate("Counter::FactoryCreate");
    auto cppIns = YR::Instance(cppCls)
                      .SetUrn("sn:cn:yrk:default:function:0-opc-opc:$latest")
                      .Invoke(1);
    auto obj = cppIns.CppFunction<int>("&Counter::Add").Invoke(1);

    return 0;
}

Note

This method is designed to be used in conjunction with CppInstanceClass or JavaInstanceClass. The URN format should follow the specified structure, and the tenant ID must be correctly configured to ensure proper functionality.

Warning

Ensure that the tenant ID in the provided URN matches the tenant ID configured in the Config. Mismatched tenant IDs may lead to errors or unexpected behavior.

Template Parameters:

Creator – The type of the creator used to construct the instance.

Parameters:

urn – The function URN to be set. This URN should be obtained after the function is deployed. The tenant ID in the URN must match the tenant ID configured in the Config. For details on tenant ID configuration, refer to the “About Tenant ID” section in the Config documentation.

Returns:

InstanceCreator<Creator> & A reference to the InstanceCreator object, allowing for a fluent interface to call the Invoke method directly.