Giter Club home page Giter Club logo

Comments (2)

taos-ci avatar taos-ci commented on July 19, 2024

:octocat: cibot: Thank you for posting issue #415. The person in charge will reply soon.

from api.

songgot avatar songgot commented on July 19, 2024

How about creating the following APIs for remote services?

static void API_NAME (handle *handle,
  const char *pipeline_description, const char *file_name, const char *file_path,
  const char *file_desccription, const char *service_type, const char *service_key, const char *topic)
{
  int ret = ML_ERROR_NONE;
  gsize len = 0;

  ret = ml_option_create (&handle->option_h);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret = ml_option_set (handle->option_h, "node-type", "remote_sender", NULL);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret = ml_option_set (handle->option_h, "dest-host", handle->broker_ip, NULL);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret = ml_option_set (handle->option_h, "dest-port", &handle->broker_port, NULL);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret = ml_option_set (handle->option_h, "connect-type", handle->connect_type, NULL);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  if (g_strcmp0(handle->connect_type, "HYBRID") == 0) {
    ret = ml_option_set (handle->option_h, "host", handle->local_ip, NULL);
    if (ML_ERROR_NONE != ret) {
      return;
    }
  }

  ret = ml_option_set (handle->option_h, "topic", (void *)topic, NULL);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret = ml_service_remote_create (handle->option_h, NULL, NULL, &handle->service_h);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret = ml_option_create (&handle->service_option_h);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret =
      ml_option_set (handle->service_option_h, "service-type", (void *)service_type, NULL); //service_type = model_raw
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret =
      ml_option_set (handle->service_option_h, "service-key", (void *)service_key, g_free); // service-key = model_registration_key
  if (ML_ERROR_NONE != ret) {
    return;
  }

  // ret = ml_option_set (handle->service_option_h, "activate", "true", NULL);
  // if (ML_ERROR_NONE != ret) {
  //   return;
  // }

  if (file_name && file_path && file_desccription) {
    ret = ml_option_set (handle->service_option_h, "name", (void *)file_name, NULL);
    if (ML_ERROR_NONE != ret) {
      return;
    }

    ret = ml_option_set (handle->service_option_h, "description", (void *)file_desccription, NULL);
    if (ML_ERROR_NONE != ret) {
      return;
    }

    dlog_print (DLOG_INFO, LOG_TAG, "transmission data:%s", file_path);

    ret = g_file_get_contents (file_path, &handle->contents, &len, NULL);
    if (FALSE == ret) {
      return;
    }
    ret = ml_service_remote_register (handle->service_h, handle->service_option_h, handle->contents, len);
    if (ML_ERROR_NONE != ret) {
      return;
    }
  } else if (pipeline_description) {
    ret =
      ml_service_remote_register (handle->service_h, handle->service_option_h, (void *)pipeline_description, strlen (pipeline_description) + 1);
    if (ML_ERROR_NONE != ret) {
      return;
    }

  } else {
    return;
  }
  return;
}

from api.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.