Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NATS structures sent to the cache service #10

Merged
merged 17 commits into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,3 @@ compile_data_attr = "glob([\"*/**\"])"
additional_build_file = "bazel/patch/BUILD_script_patch"
gen_buildrs = false
additional_deps = [":libsodium_sys_build_script"]


[package.metadata.raze.crates.value-bag.'*']
gen_buildrs = false
13 changes: 13 additions & 0 deletions cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ _DEPENDENCIES = {
},
"common/rust": {
"config": "@raze__config__0_11_0//:config",
"enumflags2": "@raze__enumflags2__0_7_1//:enumflags2",
"hyper": "@raze__hyper__0_14_12//:hyper",
"log": "@raze__log__0_4_14//:log",
"nats": "@raze__nats__0_15_2//:nats",
Expand Down Expand Up @@ -69,8 +70,10 @@ _DEPENDENCIES = {
# EXPERIMENTAL -- MAY CHANGE AT ANY TIME: A mapping of package names to a set of proc_macro dependencies for the Rust targets of that package.
_PROC_MACRO_DEPENDENCIES = {
"webhook": {
"ctor": "@raze__ctor__0_1_21//:ctor",
},
"common/rust": {
"serde_repr": "@raze__serde_repr__0_1_7//:serde_repr",
},
"gateway": {
"num-derive": "@raze__num_derive__0_3_3//:num_derive",
Expand Down Expand Up @@ -581,6 +584,16 @@ def raze_fetch_remote_crates():
build_file = Label("//cargo/remote:BUILD.crypto-mac-0.10.1.bazel"),
)

maybe(
http_archive,
name = "raze__ctor__0_1_21",
url = "https://crates.io/api/v1/crates/ctor/0.1.21/download",
type = "tar.gz",
sha256 = "ccc0a48a9b826acdf4028595adc9db92caea352f7af011a3034acd172a52a0aa",
strip_prefix = "ctor-0.1.21",
build_file = Label("//cargo/remote:BUILD.ctor-0.1.21.bazel"),
)

maybe(
http_archive,
name = "raze__curve25519_dalek__3_2_0",
Expand Down
57 changes: 57 additions & 0 deletions cargo/remote/BUILD.ctor-0.1.21.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""
@generated
cargo-raze crate build file.

DO NOT EDIT! Replaced on runs of cargo-raze
"""

# buildifier: disable=load
load("@bazel_skylib//lib:selects.bzl", "selects")

# buildifier: disable=load
load(
"@rules_rust//rust:rust.bzl",
"rust_binary",
"rust_library",
"rust_test",
)

package(default_visibility = [
# Public for visibility by "@raze__crate__version//" targets.
#
# Prefer access through "//cargo", which limits external
# visibility to explicit Cargo.toml dependencies.
"//visibility:public",
])

licenses([
"notice", # Apache-2.0 from expression "Apache-2.0 OR MIT"
])

# Generated Targets

# Unsupported target "example" with type "example" omitted

rust_library(
name = "ctor",
srcs = glob(["**/*.rs"]),
crate_features = [
],
crate_root = "src/lib.rs",
crate_type = "proc-macro",
data = [],
edition = "2018",
rustc_flags = [
"--cap-lints=allow",
],
tags = [
"cargo-raze",
"manual",
],
version = "0.1.21",
# buildifier: leave-alone
deps = [
"@raze__quote__1_0_9//:quote",
"@raze__syn__1_0_76//:syn",
],
)
3 changes: 2 additions & 1 deletion common/rust/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
load("@rules_rust//rust:defs.bzl", "rust_library")
load("//cargo:crates.bzl", "all_crate_deps")
load("//cargo:crates.bzl", "all_crate_deps", "crate_deps")

rust_library(
name = "common",
srcs = glob(["src/**"]),
proc_macro_deps = crate_deps(["serde_repr"]),
visibility = ["//visibility:public"],
deps = all_crate_deps(),
)
2 changes: 2 additions & 0 deletions common/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ edition = "2018"
pretty_env_logger = "0.4"
log = { version = "0.4", features = ["std"] }
serde = { version = "1.0.8", features = ["derive"] }
serde_repr = "0.1"
config = "0.11"
hyper = { version = "0.14", features = ["full"] }
tokio = { version = "1", features = ["full"] }
enumflags2 = { version = "0.7.1", features = ["serde"] }
prometheus = { version = "0.12.0", features = ["process"] }
nats = "0.15.2"
testcontainers = "0.12.0"
Expand Down
18 changes: 18 additions & 0 deletions common/rust/cargo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ alias(
],
)

alias(
name = "enumflags2",
actual = "@raze__enumflags2__0_7_1//:enumflags2",
tags = [
"cargo-raze",
"manual",
],
)

alias(
name = "hyper",
actual = "@raze__hyper__0_14_12//:hyper",
Expand Down Expand Up @@ -84,6 +93,15 @@ alias(
],
)

alias(
name = "serde_repr",
actual = "@raze__serde_repr__0_1_7//:serde_repr",
tags = [
"cargo-raze",
"manual",
],
)

alias(
name = "testcontainers",
actual = "@raze__testcontainers__0_12_0//:testcontainers",
Expand Down
5 changes: 4 additions & 1 deletion common/rust/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ impl<T> Settings<T>
where
T: Deserialize<'static> + std::default::Default + Clone,
{

/// Initializes a new configuration like the other components of nova
/// And starts the prometheus metrics server if needed.
pub fn new(service_name: &str) -> Result<Settings<T>, ConfigError> {
Expand All @@ -42,7 +43,9 @@ where
let mut config: Settings<T> = default.clone().try_into().unwrap();

// try to load the config
config.config = default.get::<T>(&service_name).unwrap();
config.config = default.get::<T>(service_name).unwrap();
// todo(MatthieuCodder): the following line was not present in the conflict
// pretty_env_logger::init();

// start the monitoring system if needed
crate::monitoring::start_monitoring(&config.monitoring);
Expand Down
38 changes: 38 additions & 0 deletions common/rust/src/discord_models/application.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use enumflags2::{bitflags, BitFlags};
use serde::{Deserialize, Serialize};

use super::{teams::Team, user::User};

#[bitflags]
#[repr(u64)]
#[derive(Debug, Clone, Copy)]
pub enum ApplicationFlags {
GatewayPresence = 1 << 12,
GatewayPresenceLimit = 1 << 13,
GatewayGuildMembers = 1 << 14,
GatewayGuildMembersLimited = 1 << 15,
VerificationPendingGuildLimit = 1 << 16,
Embedded = 1 << 17,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Application {
pub id: String,
pub name: String,
pub icon: Option<String>,
pub description: String,
pub rpc_origins: Option<Vec<String>>,
pub bot_public: bool,
pub bot_require_code_grant: bool,
pub terms_of_service_url: Option<String>,
pub privacy_policy_url: Option<String>,
pub owner: Option<User>,
pub summary: String,
pub verify_key: String,
pub team: Option<Team>,
pub guild_id: Option<String>,
pub primary_sku_id: Option<String>,
pub slug: Option<String>,
pub cover_image: Option<String>,
pub flags: Option<BitFlags<ApplicationFlags>>,
}
Loading