Skip to content
Open
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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ repository = "https://github.com/aesteve/buska"
[workspace]
members = [
"./core",
"./cli"
"./cli",
"./web"
]
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ indicatif = "0.17.0-beta.1"
chrono = "0.4.19"
rdkafka = { version = "0.27" , features = ["ssl", "cmake-build" ] }
serde_json = "1.0"
tokio = { version = "1.3.0", features = ["macros", "rt", "time", "sync", "rt-multi-thread"] }
tokio = { version = "1.14.0", features = ["macros", "rt", "time", "sync", "rt-multi-thread"] }
futures = "0.3"
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ keywords = ["kafka", "apache kafka", "search", "lib"]
rdkafka = { version = "0.27" , features = ["ssl", "cmake-build" ] }
serde = { version = "1.0.124", features = ["derive"] }
chrono = { version = "0.4.19", features = ["serde"] }
tokio = { version = "1.3.0", features = ["macros", "rt", "time", "sync"] }
tokio = { version = "1.14.0", features = ["macros", "rt", "time", "sync"] }
log = "0.4"
env_logger = "0.9"
jsonpath-rust = "0.1.3"
Expand Down
4 changes: 2 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ mod tests {
//clean("test").await;
//prepare("test", 60).await;
let before = Utc::now();
// let range = 1..1_000_000;
let range = 1..1_000_000;
// let range = 1_000_001..2_000_000;
// let range = 2_000_001..3_000_000;
// let range = 3_000_001..4_000_000;
Expand All @@ -565,7 +565,7 @@ mod tests {
// let range = 6_000_001..7_000_000;
// let range = 7_000_001..8_000_000;
// let range = 8_000_001..9_000_000;
let range = 9_000_001..10_000_000;
// let range = 9_000_001..10_000_000;
let recs = range.into_iter().map(|i| TestRecord { key: format!("key-{}",i), nested: NestedTestRecord {
int: i,
ints: vec![i-1, i, i+1],
Expand Down
3 changes: 2 additions & 1 deletion core/src/search/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::BTreeMap;
use std::fmt::{Display, Formatter};
use chrono::{DateTime, Duration, Utc};
use rdkafka::message::OwnedMessage;
use serde::Serialize;

#[derive(Debug, Clone)]
pub enum SearchNotification {
Expand All @@ -20,7 +21,7 @@ pub enum PreparationStep {
SeekPartitions,
}

#[derive(Debug, Clone, PartialEq)]
#[derive(Serialize, Debug, Clone, PartialEq)]
pub struct Progress {
pub done: i64,
pub total: i64,
Expand Down
25 changes: 25 additions & 0 deletions web/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "buska-web"
version = "0.0.1"
edition = "2021"
authors = ["aesteve <arnaud.esteve@gmail.com>"]
description = "A web interface for Buska: a tool to look for data in Kafka topics"
keywords = ["kafka", "apache kafka", "search", "web"]

[dependencies]
buska-core = { path = "../core" }
config = "0.11.0"
env_logger = "0.9.0"
axum = { version = "0.3.4" }
hyper = { version = "0.14.15", features = ["full"] }
tokio = { version = "1.14.0", features = ["full"] }
tokio-stream = "0.1"
tower = { version = "0.4.11", features = ["full"] }
tower-http = { version = "0.1.2", features = ["fs", "trace"] }

# common dependencies for whole project
chrono = "0.4.19"
rdkafka = { version = "0.27" , features = ["ssl", "cmake-build" ] }
serde_json = "1.0"
serde = { version = "1.0.124", features = ["derive"] }
futures = "0.3"
Empty file added web/assets/css/main.css
Empty file.
75 changes: 75 additions & 0 deletions web/assets/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- Compressed CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/foundation-sites@6.7.4/dist/css/foundation.min.css" crossorigin="anonymous">
<!-- Compressed JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/foundation-sites@6.7.4/dist/js/foundation.min.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="css/main.css" />
<style>
.main {
margin: 1%;
}
.full-progress-blue {
width: 98%;
height: 30px;
margin: 1%;
}
.full-progress-blue[value] {
width: 98%;
height: 30px;
}
.full-progress-blue::-moz-progress-bar {
background: #3E63B3;
}
.full-progress-blue {
background: transparent;
color: #3E63B3; /* For IE10 */
}
.full-progress-blue::-moz-progress-bar {
background: #3E63B3;
}
.full-progress-blue::-webkit-progress-value {
background: #3E63B3;
}

.no-style-list {
list-style-type: none;
padding: 0;
}
.no-style-list li {
padding: 0;
}
</style>
<title>BusKa Web</title>
</head>
<body>
<!--script>
</script-->
<div id="app"></div>
<script src="elm.js"></script>
<script type="application/javascript">
const app = Elm.Home.init({
node: document.getElementById('app')
});
app.ports.startSearch.subscribe(() => {
const es = new EventSource("http://localhost:3000/sse");
es.onerror = msg => {
if (msg.eventPhase === 2) {
es.close();
}
}
es.addEventListener('step', step => {
app.ports.searchStepChanged.send(JSON.parse(step.data));
});
es.addEventListener('match', match => {
app.ports.matchFound.send(match.data);
});
es.addEventListener('search-progress', p => {
app.ports.searchProgressed.send(JSON.parse(p.data));
});

});
</script>
</body>
</html>
1 change: 1 addition & 0 deletions web/front/dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
elm-live src/Home.elm -- --output='../assets/elm.js'
27 changes: 27 additions & 0 deletions web/front/elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"type": "application",
"source-directories": [
"src"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"cuducos/elm-format-number": "9.0.1",
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0",
"elm/json": "1.1.3"
},
"indirect": {
"elm/regex": "1.0.0",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.2",
"myrho/elm-round": "1.0.4"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
37 changes: 37 additions & 0 deletions web/front/src/Commands.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module Commands exposing (..)

import Json.Decode exposing (Error)
import Model exposing (Progress, SearchProgress, SearchStep, decodeSearchProgress, decodeSearchStep)


type Msg
= StartSearch
| MatchFound String
| SearchStepChanged SearchStep
| SearchProgressed SearchProgress
| DecodingError Error


receivedSearchProgress : Json.Decode.Value -> Msg
receivedSearchProgress json =
case Json.Decode.decodeValue decodeSearchProgress json of
Ok decoded ->
SearchProgressed decoded

Err message ->
DecodingError message


updateMatches : String -> Msg
updateMatches m =
MatchFound m


receivedSearchStep : Json.Decode.Value -> Msg
receivedSearchStep json =
case Json.Decode.decodeValue decodeSearchStep json of
Ok decoded ->
SearchStepChanged decoded

Err message ->
DecodingError message
68 changes: 68 additions & 0 deletions web/front/src/Home.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
module Home exposing (main)

import Browser
import Commands exposing (Msg(..), receivedSearchProgress, receivedSearchStep, updateMatches)
import Html exposing (..)
import Html.Attributes exposing (..)
import Model exposing (..)
import Ports.JSSearch exposing (matchFound, searchProgressed, searchStepChanged, startSearch)
import Views.SearchForm exposing (searchForm)
import Views.SearchProgress exposing (searchProgress)
import Views.SearchResults exposing (searchResults)


view : State -> Html Msg
view state =
div [ class "main" ]
[ h1 [] [ text "Welcome to BusKa" ]
, searchForm state
, searchProgress state
, searchResults state
]


init : () -> ( State, Cmd Msg )
init _ =
( { definition = Nothing, results = resetSearchResults }, Cmd.none )


update : Msg -> State -> ( State, Cmd Msg )
update msg state =
case msg of
StartSearch ->
( state, startSearch () )

SearchProgressed searchProgress ->
( { state | results = updateProgress state.results searchProgress }, Cmd.none )

SearchStepChanged newSearchStep ->
( { state | results = updateStep state.results newSearchStep }, Cmd.none )

DecodingError error ->
let
_ =
Debug.log "Error in decoding JSON " error
in
( state, Cmd.none )

MatchFound string ->
( { state | results = appendMatch state.results string }, Cmd.none )


subscriptions : State -> Sub Msg
subscriptions state =
Sub.batch
[ searchProgressed receivedSearchProgress
, matchFound updateMatches
, searchStepChanged receivedSearchStep
]


main : Program () State Msg
main =
Browser.element
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
}
Loading