Fixes
parent: tbd commit: 8a111d7
Showing 6 changed files with 21 insertions and 30 deletions
src/backend/git.rs
@@ -23,21 +23,21 @@ impl GitBackend { | ||
23 | 23 | impl RepositoryBackend for GitBackend { |
24 | 24 | fn create_repository( |
25 | 25 | &mut self, |
26 | request: &CreateRepositoryRequest, | |
26 | _request: &CreateRepositoryRequest, | |
27 | 27 | ) -> Result<CreateRepositoryResponse, Box<dyn Error + Send>> { |
28 | 28 | todo!() |
29 | 29 | } |
30 | 30 | |
31 | 31 | fn repository_info( |
32 | 32 | &mut self, |
33 | request: &RepositoryInfoRequest, | |
33 | _request: &RepositoryInfoRequest, | |
34 | 34 | ) -> Result<RepositoryView, Box<dyn Error + Send>> { |
35 | 35 | todo!() |
36 | 36 | } |
37 | 37 | |
38 | 38 | fn repository_file_inspect( |
39 | 39 | &mut self, |
40 | request: &RepositoryFileInspectRequest, | |
40 | _request: &RepositoryFileInspectRequest, | |
41 | 41 | ) -> Result<RepositoryFileInspectionResponse, Box<dyn Error + Send>> { |
42 | 42 | todo!() |
43 | 43 | } |
@@ -46,21 +46,21 @@ impl RepositoryBackend for GitBackend { | ||
46 | 46 | impl IssuesBackend for GitBackend { |
47 | 47 | fn issues_count( |
48 | 48 | &mut self, |
49 | request: &RepositoryIssuesCountRequest, | |
49 | _request: &RepositoryIssuesCountRequest, | |
50 | 50 | ) -> Result<RepositoryIssuesCountResponse, Box<dyn Error + Send>> { |
51 | 51 | todo!() |
52 | 52 | } |
53 | 53 | |
54 | 54 | fn issue_labels( |
55 | 55 | &mut self, |
56 | request: &RepositoryIssueLabelsRequest, | |
56 | _request: &RepositoryIssueLabelsRequest, | |
57 | 57 | ) -> Result<RepositoryIssueLabelsResponse, Box<dyn Error + Send>> { |
58 | 58 | todo!() |
59 | 59 | } |
60 | 60 | |
61 | 61 | fn issues( |
62 | 62 | &mut self, |
63 | request: &RepositoryIssuesRequest, | |
63 | _request: &RepositoryIssuesRequest, | |
64 | 64 | ) -> Result<RepositoryIssuesResponse, Box<dyn Error + Send>> { |
65 | 65 | todo!() |
66 | 66 | } |
src/connection.rs
@@ -1,8 +1,7 @@ | ||
1 | 1 | use std::{collections::HashMap, net::SocketAddr, sync::Arc}; |
2 | 2 | |
3 | use futures_util::{stream::StreamExt, SinkExt, TryStreamExt}; | |
3 | use futures_util::{stream::StreamExt, SinkExt}; | |
4 | 4 | use tokio::{ |
5 | io::{AsyncRead, AsyncWrite}, | |
6 | 5 | net::TcpStream, |
7 | 6 | sync::{ |
8 | 7 | broadcast::{Receiver, Sender}, |
@@ -14,20 +13,17 @@ use tokio_tungstenite::{tungstenite::Message, WebSocketStream}; | ||
14 | 13 | |
15 | 14 | use crate::{ |
16 | 15 | backend::{IssuesBackend, RepositoryBackend}, |
17 | handshake::{HandshakeFinalize, HandshakeMessage, HandshakeResponse, InitiateHandshake}, | |
16 | handshake::{HandshakeFinalize, HandshakeMessage, HandshakeResponse}, | |
18 | 17 | listener::Listeners, |
19 | 18 | messages::{ |
20 | issues::IssuesCountResponse, | |
21 | 19 | repository::{ |
22 | RepositoryFileInspectionResponse, RepositoryIssueLabelsResponse, | |
23 | RepositoryIssuesResponse, RepositoryMessage, RepositoryMessageKind, RepositoryRequest, | |
24 | RepositoryResponse, | |
20 | RepositoryMessage, RepositoryMessageKind, RepositoryRequest, RepositoryResponse, | |
25 | 21 | }, |
26 | 22 | MessageKind, |
27 | 23 | }, |
28 | 24 | model::{ |
29 | 25 | instance::{Instance, InstanceMeta}, |
30 | repository::{CommitMetadata, Repository, RepositoryView}, | |
26 | repository::Repository, | |
31 | 27 | user::User, |
32 | 28 | }, |
33 | 29 | }; |
@@ -56,7 +52,7 @@ pub struct Connections { | ||
56 | 52 | pub async fn connection_worker( |
57 | 53 | mut socket: WebSocketStream<TcpStream>, |
58 | 54 | listeners: Arc<Mutex<Listeners>>, |
59 | mut connections: Arc<Mutex<Connections>>, | |
55 | connections: Arc<Mutex<Connections>>, | |
60 | 56 | backend: Arc<Mutex<dyn RepositoryBackend + Send>>, |
61 | 57 | addr: SocketAddr, |
62 | 58 | ) { |
@@ -355,7 +351,7 @@ pub async fn connection_worker( | ||
355 | 351 | .unwrap(); |
356 | 352 | } |
357 | 353 | }, |
358 | RepositoryMessageKind::Response(response) => { | |
354 | RepositoryMessageKind::Response(_response) => { | |
359 | 355 | unreachable!() |
360 | 356 | } |
361 | 357 | } |
@@ -369,7 +365,7 @@ pub async fn connection_worker( | ||
369 | 365 | async fn send_and_get_listener( |
370 | 366 | message: MessageKind, |
371 | 367 | listeners: &Arc<Mutex<Listeners>>, |
372 | mut connections: &Arc<Mutex<Connections>>, | |
368 | connections: &Arc<Mutex<Connections>>, | |
373 | 369 | ) -> Receiver<MessageKind> { |
374 | 370 | let (instance, user, repository): (Option<Instance>, Option<User>, Option<Repository>) = |
375 | 371 | match &message { |
@@ -387,7 +383,7 @@ async fn send_and_get_listener( | ||
387 | 383 | }; |
388 | 384 | |
389 | 385 | let mut listeners = listeners.lock().await; |
390 | let mut listener = listeners.add(instance, user, repository); | |
386 | let listener = listeners.add(instance, user, repository); | |
391 | 387 | drop(listeners); |
392 | 388 | |
393 | 389 | let connections = connections.lock().await; |
src/listener.rs
@@ -15,9 +15,9 @@ pub struct Listeners { | ||
15 | 15 | impl Listeners { |
16 | 16 | pub fn add( |
17 | 17 | &mut self, |
18 | instance: Option<Instance>, | |
19 | user: Option<User>, | |
20 | repository: Option<Repository>, | |
18 | _instance: Option<Instance>, | |
19 | _user: Option<User>, | |
20 | _repository: Option<Repository>, | |
21 | 21 | ) -> Receiver<MessageKind> { |
22 | 22 | todo!() |
23 | 23 | } |
src/main.rs
@@ -1,6 +1,6 @@ | ||
1 | 1 | use std::{error::Error, net::SocketAddr, sync::Arc}; |
2 | 2 | |
3 | use connection::{connection_worker, Connections, RawConnection, UnestablishedConnection}; | |
3 | use connection::{connection_worker, Connections, RawConnection}; | |
4 | 4 | use giterated_daemon::{ |
5 | 5 | backend::{git::GitBackend, RepositoryBackend}, |
6 | 6 | connection, listener, |
@@ -20,10 +20,9 @@ extern crate tracing; | ||
20 | 20 | async fn main() -> Result<(), Box<dyn Error>> { |
21 | 21 | tracing_subscriber::fmt::init(); |
22 | 22 | let mut listener = TcpListener::bind("127.0.0.1:8080").await?; |
23 | let mut connections: Arc<Mutex<Connections>> = Arc::default(); | |
24 | let mut listeners: Arc<Mutex<Listeners>> = Arc::default(); | |
25 | let mut backend: Arc<Mutex<dyn RepositoryBackend + Send>> = | |
26 | Arc::new(Mutex::new(GitBackend::new())); | |
23 | let connections: Arc<Mutex<Connections>> = Arc::default(); | |
24 | let listeners: Arc<Mutex<Listeners>> = Arc::default(); | |
25 | let backend: Arc<Mutex<dyn RepositoryBackend + Send>> = Arc::new(Mutex::new(GitBackend::new())); | |
27 | 26 | |
28 | 27 | loop { |
29 | 28 | let stream = accept_stream(&mut listener).await; |