Skip to content

Commit 8e941ba

Browse files
reorganize proto files a bit (#30)
1 parent b1b3e6a commit 8e941ba

File tree

22 files changed

+225
-210
lines changed

22 files changed

+225
-210
lines changed

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ trim_trailing_whitespace = true
99
[{,.}{j,J}ustfile]
1010
indent_size = 4
1111

12-
[*.{just,proto,py,rst,ini,md}]
12+
[*.{just,py,rst,ini,md}]
1313
indent_size = 4
1414

1515
[*.py]
1616
line_length = 120
1717
multi_line_output = 3
1818

19-
[*.{css,html,js,json,jsx,sass,scss,svelte,ts,tsx,yml,yaml}]
19+
[*.{css,html,js,json,jsx,proto,sass,scss,svelte,ts,tsx,yml,yaml}]
2020
indent_size = 2
2121

2222
[*.md]

crates/djls-django/src/django.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl DjangoProject {
2323
pub fn setup(mut python: PythonProcess) -> Result<Self, ProjectError> {
2424
let py = Python::setup(&mut python)?;
2525

26-
match check::GeoDjangoPrereqsRequest::execute(&mut python)?.result {
26+
match commands::check::GeoDjangoPrereqsRequest::execute(&mut python)?.result {
2727
Some(messages::response::Result::CheckGeodjangoPrereqs(response)) => {
2828
if !response.passed {
2929
eprintln!("Warning: GeoDjango detected but GDAL is not available.");
@@ -43,7 +43,7 @@ impl DjangoProject {
4343
_ => Err(ProcessError::Response)?,
4444
}
4545

46-
let response = django::GetProjectInfoRequest::execute(&mut python)?;
46+
let response = commands::django::GetProjectInfoRequest::execute(&mut python)?;
4747

4848
let version = match response.result {
4949
Some(messages::response::Result::DjangoGetProjectInfo(response)) => {

crates/djls-ipc/src/commands.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub trait IpcCommand: Default {
1313
}
1414
}
1515

16-
impl IpcCommand for v1::check::HealthRequest {
16+
impl IpcCommand for v1::commands::check::HealthRequest {
1717
fn into_request(&self) -> messages::Request {
1818
messages::Request {
1919
command: Some(messages::request::Command::CheckHealth(*self)),
@@ -29,7 +29,7 @@ impl IpcCommand for v1::check::HealthRequest {
2929
}
3030
}
3131

32-
impl IpcCommand for v1::check::GeoDjangoPrereqsRequest {
32+
impl IpcCommand for v1::commands::check::GeoDjangoPrereqsRequest {
3333
fn into_request(&self) -> messages::Request {
3434
messages::Request {
3535
command: Some(messages::request::Command::CheckGeodjangoPrereqs(*self)),
@@ -45,7 +45,7 @@ impl IpcCommand for v1::check::GeoDjangoPrereqsRequest {
4545
}
4646
}
4747

48-
impl IpcCommand for v1::python::GetEnvironmentRequest {
48+
impl IpcCommand for v1::commands::python::GetEnvironmentRequest {
4949
fn into_request(&self) -> messages::Request {
5050
messages::Request {
5151
command: Some(messages::request::Command::PythonGetEnvironment(*self)),
@@ -61,7 +61,7 @@ impl IpcCommand for v1::python::GetEnvironmentRequest {
6161
}
6262
}
6363

64-
impl IpcCommand for v1::django::GetProjectInfoRequest {
64+
impl IpcCommand for v1::commands::django::GetProjectInfoRequest {
6565
fn into_request(&self) -> messages::Request {
6666
messages::Request {
6767
command: Some(messages::request::Command::DjangoGetProjectInfo(*self)),

crates/djls-ipc/src/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl PythonProcess {
7979
) -> Result<(), ProcessError> {
8080
let request = messages::Request {
8181
command: Some(messages::request::Command::CheckHealth(
82-
check::HealthRequest {},
82+
commands::check::HealthRequest {},
8383
)),
8484
};
8585

crates/djls-ipc/src/proto.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
pub mod v1 {
2-
pub mod messages {
3-
include!(concat!(env!("OUT_DIR"), "/djls.v1.messages.rs"));
4-
}
5-
6-
pub mod check {
7-
include!(concat!(env!("OUT_DIR"), "/djls.v1.check.rs"));
2+
pub mod commands {
3+
include!(concat!(env!("OUT_DIR"), "/djls.v1.commands.rs"));
84
}
95

106
pub mod django {
117
include!(concat!(env!("OUT_DIR"), "/djls.v1.django.rs"));
128
}
139

10+
pub mod messages {
11+
include!(concat!(env!("OUT_DIR"), "/djls.v1.messages.rs"));
12+
}
13+
1414
pub mod python {
1515
include!(concat!(env!("OUT_DIR"), "/djls.v1.python.rs"));
1616
}

crates/djls-python/src/python.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub struct Python {
9191

9292
impl Python {
9393
pub fn setup(python: &mut PythonProcess) -> Result<Self, PythonError> {
94-
let response = python::GetEnvironmentRequest::execute(python)?;
94+
let response = commands::python::GetEnvironmentRequest::execute(python)?;
9595
match response.result {
9696
Some(messages::response::Result::PythonGetEnvironment(response)) => response
9797
.python

proto/v1/check.proto

Lines changed: 0 additions & 15 deletions
This file was deleted.

proto/v1/commands.proto

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
syntax = "proto3";
2+
3+
package djls.v1.commands;
4+
5+
import "v1/django.proto";
6+
import "v1/python.proto";
7+
8+
message Check {
9+
message HealthRequest {}
10+
message HealthResponse {
11+
bool passed = 1;
12+
optional string error = 2;
13+
}
14+
15+
message GeoDjangoPrereqsRequest {}
16+
message GeoDjangoPrereqsResponse {
17+
bool passed = 1;
18+
optional string error = 2;
19+
}
20+
}
21+
22+
message Python {
23+
message GetEnvironmentRequest {}
24+
message GetEnvironmentResponse {
25+
python.Python python = 1;
26+
}
27+
}
28+
29+
message Django {
30+
message GetProjectInfoRequest {}
31+
message GetProjectInfoResponse {
32+
django.Project project = 1;
33+
}
34+
}
35+

proto/v1/django.proto

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@ syntax = "proto3";
22

33
package djls.v1.django;
44

5-
// models
65
message Project {
76
string version = 3;
87
}
9-
10-
// commands
11-
message GetProjectInfoRequest {}
12-
13-
message GetProjectInfoResponse {
14-
Project project = 1;
15-
}

proto/v1/messages.proto

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,23 @@ syntax = "proto3";
22

33
package djls.v1.messages;
44

5-
import "v1/check.proto";
6-
import "v1/django.proto";
7-
import "v1/python.proto";
5+
import "v1/commands.proto";
86

97
message Request {
108
oneof command {
11-
check.HealthRequest check__health = 1;
12-
check.GeoDjangoPrereqsRequest check__geodjango_prereqs = 2;
13-
python.GetEnvironmentRequest python__get_environment = 1000;
14-
django.GetProjectInfoRequest django__get_project_info = 2000;
9+
commands.Check.HealthRequest check__health = 1;
10+
commands.Check.GeoDjangoPrereqsRequest check__geodjango_prereqs = 2;
11+
commands.Python.GetEnvironmentRequest python__get_environment = 1000;
12+
commands.Django.GetProjectInfoRequest django__get_project_info = 2000;
1513
}
1614
}
1715

1816
message Response {
1917
oneof result {
20-
check.HealthResponse check__health = 1;
21-
check.GeoDjangoPrereqsResponse check__geodjango_prereqs = 2;
22-
python.GetEnvironmentResponse python__get_environment = 1000;
23-
django.GetProjectInfoResponse django__get_project_info = 2000;
18+
commands.Check.HealthResponse check__health = 1;
19+
commands.Check.GeoDjangoPrereqsResponse check__geodjango_prereqs = 2;
20+
commands.Python.GetEnvironmentResponse python__get_environment = 1000;
21+
commands.Django.GetProjectInfoResponse django__get_project_info = 2000;
2422
Error error = 9000;
2523
}
2624
}

0 commit comments

Comments
 (0)