Using many enum for static data instead of store they in in-memory table

our server take a request and with many rules generates a json.

for static data, we want move to enum for all things because
its great and increase simplicity and avoid locking ( in prev version
we used in-memory data structure, first load from from then store in-memory
vectors with RwLock for concurrent access )

we decision to use hierarchy of Enum because serde_json
very good and clean parse it to json.

its good way for access to static data, avoid lock, concurrent access ??

I don't understand in what way you are using enums to avoid locking?

1 Like

like bellow sample,
we have static data and never it change,

but we need choice and send to client or reverse
in client instead of ( send id of row in table and we get from table with locking of concurrency access ) ,
just send string, and in server serde_json very simple
parse for our,

this is just sample

enum Client {
     Admin(i32),
     Member(i32),
     Guest(i32)
}

enum Requirement {
    Ram(i32),
    Disk(i32),
    Cpu(i32),
}

enum CType {
   Container, 
   Machine
}

struct Program {
  filename: Vec<U8>,
  data: Vec<u8>
}

enum Label {
 None,
 Reason(String)
}

enum Query {
   Rent(Client, CType, Requirement, Program, Label),
   Bridge(Client, Client),
   AccessTo(Client, Client)
} 

in prev version, we stored all in in-memory table and get from it,
that made locking for concurrenet access and ....

I think this pattern very improve performance.
Enum and serde are great

I have no idea what you are talking about, honestly. Maybe you could give an example of the version of the code that has locks?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.