Compare commits
4
Commits
improved_docs
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d38f3c24e8 | ||
|
|
544a07c63b | ||
|
|
8f4d51d28c | ||
|
|
4db0a934c5 |
@@ -9,6 +9,10 @@ ToastyFS is a simple, fault-tolerant, highly available object storage featuring:
|
||||
|
||||
I initially started this project to learn about distributed systems. I asked myself what it would take to build my own Dropbox. A rabbit-hole later and here is my distributed storage system!
|
||||
|
||||
Here is a cool pic of the hardware I'm building to run ToastyFS :D
|
||||
|
||||

|
||||
|
||||
## Table of Contents
|
||||
|
||||
* [ToastyFS](#toastyfs)
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
const std = @import("std");
|
||||
|
||||
const include_paths: []const []const u8 = &.{
|
||||
".",
|
||||
"src",
|
||||
"include",
|
||||
"quakey/include",
|
||||
};
|
||||
|
||||
const files: []const []const u8 = &.{
|
||||
|
||||
"src/chunk_store.c",
|
||||
"src/client.c",
|
||||
"src/client_table.c",
|
||||
"src/http_proxy.c",
|
||||
"src/invariant_checker.c",
|
||||
"src/log.c",
|
||||
"src/main.c",
|
||||
"src/metadata.c",
|
||||
"src/random_client.c",
|
||||
"src/server.c",
|
||||
|
||||
"lib/basic.c",
|
||||
"lib/byte_queue.c",
|
||||
"lib/file_system.c",
|
||||
"lib/http_parse.c",
|
||||
"lib/http_server.c",
|
||||
"lib/message.c",
|
||||
"lib/tcp.c",
|
||||
"lib/tls_openssl.c",
|
||||
"lib/tls_schannel.c",
|
||||
|
||||
"quakey/src/mockfs.c",
|
||||
"quakey/src/quakey.c",
|
||||
};
|
||||
|
||||
fn buildTarget(b: *std.Build, name: []const u8, macros: []const []const u8, flags: []const []const u8) void {
|
||||
const exe = b.addExecutable(.{
|
||||
.name = name,
|
||||
.root_module = b.createModule(.{
|
||||
.target = b.graph.host,
|
||||
}),
|
||||
});
|
||||
for (macros) |m| {
|
||||
exe.root_module.addCMacro(m, "");
|
||||
}
|
||||
for (include_paths) |p| {
|
||||
exe.root_module.addIncludePath(b.path(p));
|
||||
}
|
||||
exe.root_module.addCSourceFiles(.{ .files = files, .flags = flags });
|
||||
exe.root_module.link_libc = true;
|
||||
|
||||
b.installArtifact(exe);
|
||||
}
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
|
||||
// Server
|
||||
buildTarget(b,
|
||||
"toasty",
|
||||
&.{ "MAIN_SERVER" },
|
||||
&.{ "-Wall", "-Wextra", "-ggdb", "-O0" },
|
||||
);
|
||||
|
||||
// Client
|
||||
buildTarget(b,
|
||||
"toasty_random_client",
|
||||
&.{ "MAIN_CLIENT" },
|
||||
&.{ "-Wall", "-Wextra", "-ggdb", "-O0" },
|
||||
);
|
||||
|
||||
// Proxy
|
||||
buildTarget(b,
|
||||
"toasty_proxy",
|
||||
&.{ "MAIN_HTTP_PROXY" },
|
||||
&.{ "-Wall", "-Wextra", "-ggdb", "-O0" },
|
||||
);
|
||||
|
||||
// Simulation
|
||||
buildTarget(b,
|
||||
"toasty_simulation",
|
||||
&.{ "MAIN_SIMULATION", "FAULT_INJECTION" },
|
||||
&.{ "-Wall", "-Wextra", "-ggdb", "-O0" },
|
||||
);
|
||||
}
|
||||
+33
-5
@@ -19,6 +19,10 @@ int http_proxy_init(void *state, int argc, char **argv,
|
||||
char *addrs[NODE_LIMIT];
|
||||
int num_addrs = 0;
|
||||
|
||||
int max_opers = 128;
|
||||
string http_addr = S("127.0.0.1:3000");
|
||||
uint64_t client_id = 999;
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (!strcmp(argv[i], "--server")) {
|
||||
i++;
|
||||
@@ -32,16 +36,40 @@ int http_proxy_init(void *state, int argc, char **argv,
|
||||
}
|
||||
addrs[num_addrs] = argv[i];
|
||||
num_addrs++;
|
||||
} else if (!strcmp(argv[i], "--addr")) {
|
||||
i++;
|
||||
if (i == argc) {
|
||||
fprintf(stderr, "Option --addr missing value\n");
|
||||
return -1;
|
||||
}
|
||||
http_addr = (string) { argv[i], strlen(argv[i]) };
|
||||
} else if (!strcmp(argv[i], "--max-ops")) {
|
||||
i++;
|
||||
if (i == argc) {
|
||||
fprintf(stderr, "Option --max-ops missing value\n");
|
||||
return -1;
|
||||
}
|
||||
max_opers = atoi(argv[i]); // TODO: don't use atoi
|
||||
if (max_opers == 0) {
|
||||
fprintf(stderr, "Invalid value for option --max-ops\n");
|
||||
return -1;
|
||||
}
|
||||
} else if (!strcmp(argv[i], "--client-id")) {
|
||||
i++;
|
||||
if (i == argc) {
|
||||
fprintf(stderr, "Invalid value for option --client-id\n");
|
||||
return -1;
|
||||
}
|
||||
client_id = atoi(argv[i]);
|
||||
if (client_id == 0) {
|
||||
fprintf(stderr, "Invalid value for option --client-id\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
// Ignore unknown options
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Make these configurable
|
||||
int max_opers = 128;
|
||||
string http_addr = S("127.0.0.1:3000");
|
||||
uint64_t client_id = 999;
|
||||
|
||||
proxy->max_opers = max_opers;
|
||||
proxy->opers = malloc(max_opers * sizeof(ProxyOper));
|
||||
if (proxy->opers == NULL)
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ static void node_log_impl(Server *state, const char *event, const char *detail)
|
||||
static int count_set(uint32_t word)
|
||||
{
|
||||
int n = 0;
|
||||
for (int i = 0; i < (int) sizeof(word) * 8; i++)
|
||||
for (int i = 0; i < (int) sizeof(word) * 8 - 1; i++)
|
||||
if (word & (1 << i))
|
||||
n++;
|
||||
return n;
|
||||
|
||||
Reference in New Issue
Block a user