Skip to content

Commit

Permalink
chore: updated to load words static
Browse files Browse the repository at this point in the history
  • Loading branch information
paulobressan committed Aug 6, 2024
1 parent 4613cab commit 88b14fe
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 152 deletions.
52 changes: 0 additions & 52 deletions data/adjectives.json

This file was deleted.

52 changes: 0 additions & 52 deletions data/nouns.json

This file was deleted.

1 change: 1 addition & 0 deletions docker/dockerfile.daemon
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ RUN apt update
RUN apt install -y libssl-dev libsasl2-dev

COPY --from=build /app/target/release/ ./

CMD ["./daemon"]
LABEL service=daemon
3 changes: 0 additions & 3 deletions docker/dockerfile.rpc
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ RUN cargo build --release --bin=rpc

FROM rust:1.79-slim-buster

WORKDIR /fabric

RUN apt update
RUN apt install -y libssl-dev libsasl2-dev

COPY --from=build /app/target/release/rpc .
COPY ./data ./data

CMD ["./rpc"]
LABEL service=rpc
45 changes: 0 additions & 45 deletions src/domain/utils.rs

This file was deleted.

50 changes: 50 additions & 0 deletions src/domain/utils/adjectives
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
tasteful
existing
charming
ethereal
faithful
imported
parallel
fearless
accurate
material
juvenile
nebulous
powerful
adorable
truthful
freezing
peaceful
precious
absorbed
aromatic
detailed
assorted
exciting
separate
actually
skillful
hallowed
cultured
succinct
possible
medieval
romantic
magnetic
fabulous
metallic
singular
harmonic
bohemian
synaptic
greenish
vitreous
wearable
cetacean
oracular
viridian
aquarian
sidereal
diatonic
granular
platonic
25 changes: 25 additions & 0 deletions src/domain/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use rand::distributions::Alphanumeric;
use rand::Rng;

const ADJECTIVES: &str = include_str!("adjectives");
const NOUNS: &str = include_str!("nouns");

fn get_random_word(list: Vec<&str>) -> String {
let mut rng = rand::thread_rng();
let idx = rng.gen_range(0..list.len());
list[idx].to_string()
}

pub fn get_random_name() -> String {
let salt: String = rand::thread_rng()
.sample_iter(&Alphanumeric)
.filter(|c| c.is_ascii_lowercase() || c.is_ascii_digit())
.take(6)
.map(char::from)
.collect();

let adjective = get_random_word(ADJECTIVES.lines().collect());
let noun = get_random_word(NOUNS.lines().collect());

format!("{adjective}-{noun}-{salt}")
}
50 changes: 50 additions & 0 deletions src/domain/utils/nouns
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
sympathy
election
politics
patience
analysis
teaching
contract
guidance
internet
homework
audience
birthday
quantity
customer
employee
relation
magazine
emphasis
elevator
ambition
argument
presence
priority
reaction
baseball
language
midnight
delivery
attitude
stranger
decision
republic
property
category
strategy
director
addition
kindness
calmness
gladness
laughter
appetite
elegance
aircraft
infusion
aerobics
dinosaur
catapult
zeppelin
broccoli

0 comments on commit 88b14fe

Please sign in to comment.