Skip to content

Commit

Permalink
Initial project setup from template
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorier authored and github-actions[bot] committed Mar 21, 2024
1 parent 6f03f2d commit 46d8aa4
Show file tree
Hide file tree
Showing 34 changed files with 603 additions and 804 deletions.
111 changes: 0 additions & 111 deletions .github/initial-setup.py

This file was deleted.

32 changes: 0 additions & 32 deletions .github/workflows/setup.yml

This file was deleted.

12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2020 The University of Chicago
# See COPYRIGHT in top-level directory.
cmake_minimum_required (VERSION 3.8)
project (alpha C CXX)
project (flock C CXX)
enable_testing ()

add_definitions (-Wextra -Wall -Wpedantic)
Expand Down Expand Up @@ -56,11 +56,11 @@ pkg_check_modules (margo REQUIRED IMPORTED_TARGET margo)
pkg_check_modules (json-c REQUIRED IMPORTED_TARGET json-c)

# library version set here (e.g. for shared libs).
set (ALPHA_VERSION_MAJOR 0)
set (ALPHA_VERSION_MINOR 1)
set (ALPHA_VERSION_PATCH 0)
set (ALPHA_VERSION
"${ALPHA_VERSION_MAJOR}.${ALPHA_VERSION_MINOR}.${ALPHA_VERSION_PATCH}")
set (FLOCK_VERSION_MAJOR 0)
set (FLOCK_VERSION_MINOR 1)
set (FLOCK_VERSION_PATCH 0)
set (FLOCK_VERSION
"${FLOCK_VERSION_MAJOR}.${FLOCK_VERSION_MINOR}.${FLOCK_VERSION_PATCH}")

add_subdirectory (src)
if (${ENABLE_TESTS})
Expand Down
38 changes: 0 additions & 38 deletions COPYRIGHT

This file was deleted.

20 changes: 2 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@
Margo Microservice Template
===========================

This project is a template to start developing a Mochi microservice based on Margo.
The complete documentation to get started using this template is available
[here](https://mochi.readthedocs.io/en/latest/templates/01_margo.html).

To use this template:
- Click on the green "Use this template" button at the top.
- Give a name to your project.
- Once your project repository is created, go to Settings > Actions > General and give "Read and write permissions" under *Workflow permissions*.
- Finally, edit the initial-setup.json file and push the changes to your repo.

Editing the initial-setup.json file with trigger a github action that will
cleanup your repository and rename files, namespaces, functions, etc. according
to the name of your service and the resources it manages.

Enjoy working with Mochi!
Your project "flock" has been setup!
Enjoy programming with Mochi!
4 changes: 2 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_executable (example-server ${CMAKE_CURRENT_SOURCE_DIR}/server.c)
target_link_libraries (example-server alpha-server)
target_link_libraries (example-server flock-server)

add_executable (example-client ${CMAKE_CURRENT_SOURCE_DIR}/client.c)
target_link_libraries (example-client alpha-client)
target_link_libraries (example-client flock-client)
8 changes: 4 additions & 4 deletions examples/bedrock-config.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"libraries": {
"alpha": "libalpha-bedrock-module.so"
"flock": "libflock-bedrock-module.so"
},
"providers": [
{
"type": "alpha",
"name": "my-alpha-provider",
"type": "flock",
"name": "my-flock-provider",
"provider_id": 42,
"config": {
"resource": {
"group": {
"type": "dummy",
"config": {}
}
Expand Down
46 changes: 23 additions & 23 deletions examples/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <stdlib.h>
#include <margo.h>
#include <assert.h>
#include <alpha/alpha-client.h>
#include <alpha/alpha-resource.h>
#include <flock/flock-client.h>
#include <flock/flock-group.h>

#define FATAL(...) \
do { \
Expand All @@ -23,7 +23,7 @@ int main(int argc, char** argv)
exit(-1);
}

alpha_return_t ret;
flock_return_t ret;
hg_return_t hret;
const char* svr_addr_str = argv[1];
uint16_t provider_id = atoi(argv[2]);
Expand All @@ -39,39 +39,39 @@ int main(int argc, char** argv)
FATAL(mid,"margo_addr_lookup failed for address %s", svr_addr_str);
}

alpha_client_t alpha_clt;
alpha_resource_handle_t alpha_rh;
flock_client_t flock_clt;
flock_group_handle_t flock_rh;

margo_info(mid, "Creating ALPHA client");
ret = alpha_client_init(mid, &alpha_clt);
if(ret != ALPHA_SUCCESS) {
FATAL(mid,"alpha_client_init failed (ret = %d)", ret);
margo_info(mid, "Creating FLOCK client");
ret = flock_client_init(mid, &flock_clt);
if(ret != FLOCK_SUCCESS) {
FATAL(mid,"flock_client_init failed (ret = %d)", ret);
}

margo_info(mid, "Creating resource handle for provider id %d", (int)provider_id);
ret = alpha_resource_handle_create(alpha_clt, svr_addr, provider_id, true, &alpha_rh);
if(ret != ALPHA_SUCCESS) {
FATAL(mid,"alpha_resource_handle_create failed (ret = %d)", ret);
margo_info(mid, "Creating group handle for provider id %d", (int)provider_id);
ret = flock_group_handle_create(flock_clt, svr_addr, provider_id, true, &flock_rh);
if(ret != FLOCK_SUCCESS) {
FATAL(mid,"flock_group_handle_create failed (ret = %d)", ret);
}

margo_info(mid, "Computing sum");
int32_t result;
ret = alpha_compute_sum(alpha_rh, 45, 23, &result);
if(ret != ALPHA_SUCCESS) {
FATAL(mid,"alpha_compute_sum failed (ret = %d)", ret);
ret = flock_compute_sum(flock_rh, 45, 23, &result);
if(ret != FLOCK_SUCCESS) {
FATAL(mid,"flock_compute_sum failed (ret = %d)", ret);
}
margo_info(mid, "45 + 23 = %d", result);

margo_info(mid, "Releasing resource handle");
ret = alpha_resource_handle_release(alpha_rh);
if(ret != ALPHA_SUCCESS) {
FATAL(mid,"alpha_resource_handle_release failed (ret = %d)", ret);
margo_info(mid, "Releasing group handle");
ret = flock_group_handle_release(flock_rh);
if(ret != FLOCK_SUCCESS) {
FATAL(mid,"flock_group_handle_release failed (ret = %d)", ret);
}

margo_info(mid, "Finalizing client");
ret = alpha_client_finalize(alpha_clt);
if(ret != ALPHA_SUCCESS) {
FATAL(mid,"alpha_client_finalize failed (ret = %d)", ret);
ret = flock_client_finalize(flock_clt);
if(ret != FLOCK_SUCCESS) {
FATAL(mid,"flock_client_finalize failed (ret = %d)", ret);
}

hret = margo_addr_free(mid, svr_addr);
Expand Down
8 changes: 4 additions & 4 deletions examples/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <assert.h>
#include <stdio.h>
#include <margo.h>
#include <alpha/alpha-server.h>
#include <flock/flock-server.h>

int main(int argc, char** argv)
{
Expand All @@ -25,11 +25,11 @@ int main(int argc, char** argv)
margo_addr_free(mid,my_address);
margo_info(mid, "Server running at address %s, with provider id 42", addr_str);

struct alpha_provider_args args = ALPHA_PROVIDER_ARGS_INIT;
struct flock_provider_args args = FLOCK_PROVIDER_ARGS_INIT;

const char* config = "{ \"resource\":{ \"type\":\"dummy\", \"config\":{} } }";
const char* config = "{ \"group\":{ \"type\":\"dummy\", \"config\":{} } }";

alpha_provider_register(mid, 42, config, &args, ALPHA_PROVIDER_IGNORE);
flock_provider_register(mid, 42, config, &args, FLOCK_PROVIDER_IGNORE);

margo_wait_for_finalize(mid);

Expand Down
Loading

0 comments on commit 46d8aa4

Please sign in to comment.