Skip to content

Commit

Permalink
move to another file
Browse files Browse the repository at this point in the history
  • Loading branch information
lmatz committed Dec 8, 2022
1 parent 3c4ebce commit a4f6390
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 41 deletions.
41 changes: 41 additions & 0 deletions src/connector/src/source/nexmark/source/combined_event.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use nexmark::event::{Auction, Bid, Person};
use serde::{Deserialize, Serialize};

#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct CombinedEvent {
event_type: u64,
/// The Person event
person: Option<Person>,
/// The Auction event.
auction: Option<Auction>,
/// The Bid event.
bid: Option<Bid>,
}

impl CombinedEvent {
fn new(
event_type: u64,
person: Option<Person>,
auction: Option<Auction>,
bid: Option<Bid>,
) -> Self {
Self {
event_type,
person,
auction,
bid,
}
}

pub fn person(person: Person) -> Self {
Self::new(0, Some(person), None, None)
}

pub fn auction(auction: Auction) -> Self {
Self::new(1, None, Some(auction), None)
}

pub fn bid(bid: Bid) -> Self {
Self::new(2, None, None, Some(bid))
}
}
43 changes: 2 additions & 41 deletions src/connector/src/source/nexmark/source/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
// limitations under the License.

use bytes::Bytes;
use nexmark::event::{Auction, Bid, Event, Person};
use serde::{Deserialize, Serialize};
use nexmark::event::Event;

use crate::source::nexmark::source::combined_event::CombinedEvent;
use crate::source::{SourceMessage, SplitId};

#[derive(Clone, Debug)]
Expand All @@ -35,45 +35,6 @@ impl From<NexmarkMessage> for SourceMessage {
}
}

#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
struct CombinedEvent {
event_type: u64,
/// The Person event
person: Option<Person>,
/// The Auction event.
auction: Option<Auction>,
/// The Bid event.
bid: Option<Bid>,
}

impl CombinedEvent {
fn new(
event_type: u64,
person: Option<Person>,
auction: Option<Auction>,
bid: Option<Bid>,
) -> Self {
Self {
event_type,
person,
auction,
bid,
}
}

fn person(person: Person) -> Self {
Self::new(0, Some(person), None, None)
}

fn auction(auction: Auction) -> Self {
Self::new(1, None, Some(auction), None)
}

fn bid(bid: Bid) -> Self {
Self::new(2, None, None, Some(bid))
}
}

impl NexmarkMessage {
pub fn new(split_id: SplitId, offset: u64, event: Event) -> Self {
let combined_event = match event {
Expand Down
1 change: 1 addition & 0 deletions src/connector/src/source/nexmark/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

mod combined_event;
pub mod message;
pub mod reader;

0 comments on commit a4f6390

Please sign in to comment.