Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* dev:
  version number and changelog
  Spell check
  • Loading branch information
najamelan committed Sep 23, 2019
2 parents d26d98d + 892fd0f commit 10dcf85
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 59 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Pharos Changelog

## 0.3.2 - 2019-09-23

- check spelling

## 0.3.1 - 2019-09-23

**BREAKING CHANGE**: Last minute change of heart. I removed two API methods whose only "merit" was
- **BREAKING CHANGE**: Last minute change of heart. I removed two API methods whose only "merit" was
to hide a Box::new from the user.
- fix docs.rs showing readme

## 0.3.0 - 2019-09-23 - yanked

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ license = "Unlicense"
name = "pharos"
readme = "README.md"
repository = "https://github.com/najamelan/pharos"
version = "0.3.1"
version = "0.3.2"

[package.metadata]
[package.metadata.docs]
Expand Down
2 changes: 1 addition & 1 deletion Cargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package:
# - merge dev branch into master
# - create git tag
#
version : 0.3.1
version : 0.3.2
name : pharos
authors : [ Naja Melan <[email protected]> ]
edition : '2018'
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Minimal rustc version: 1.39.

## Security

The main issue with this crate right now is the posibility for the observable to outpace the observer. When using bounded channels, there is back pressure, which might allow DDOS attacks if using the pattern on arriving network packets. When using the unbounded channels, it might lead to excessive memory consumption if observers are outpaced.
The main issue with this crate right now is the possibility for the observable to outpace the observer. When using bounded channels, there is back pressure, which might allow DDOS attacks if using the pattern on arriving network packets. When using the unbounded channels, it might lead to excessive memory consumption if observers are outpaced.

TODO: To mitigate these problems effectively, I will add a ring channel where the channel will only buffer a certain amount events and will overwrite the oldest event instead of blocking the sender when the buffer is full.

Expand All @@ -40,8 +40,8 @@ This crate has: `#![ forbid( unsafe_code ) ]`

### Limitations

- only bounded and unbounded channel as backend (for now)
- [`Events`] is not clonable right now (would require support from the channels we use as backends, eg. broadcast type channel)
- only bounded and unbounded channel as back-end (for now)
- [`Events`] is not clonable right now (would require support from the channels we use as back-ends, eg. broadcast type channel)
- performance tweaking still needs to be done
- pharos requires mut access for most operations. This is not intended to change anytime soon. Both on
[notify](Pharos::notify) and [observe](Observable::observe), the two main interfaces, manipulate internal
Expand Down Expand Up @@ -79,7 +79,7 @@ Please check out the [changelog](https://github.com/najamelan/pharos/blob/master

### Dependencies

This crate only has two dependiencies. Cargo will automatically handle it's dependencies for you.
This crate only has two dependencies. Cargo will automatically handle it's dependencies for you.

```yaml
dependencies:
Expand Down Expand Up @@ -109,21 +109,21 @@ use
// here we put a pharos object on our struct
//
struct Godess { pharos: Pharos<GodessEvent> }
struct Goddess { pharos: Pharos<GoddessEvent> }
impl Godess
impl Goddess
{
fn new() -> Self
{
Self { pharos: Pharos::default() }
}
// Send Godess sailing so she can tweet about it!
// Send Goddess sailing so she can tweet about it!
//
pub async fn sail( &mut self )
{
self.pharos.notify( &GodessEvent::Sailing ).await;
self.pharos.notify( &GoddessEvent::Sailing ).await;
}
}
Expand All @@ -134,7 +134,7 @@ impl Godess
//
#[ derive( Clone, Debug, PartialEq, Copy ) ]
//
enum GodessEvent
enum GoddessEvent
{
Sailing
}
Expand All @@ -145,9 +145,9 @@ enum GodessEvent
// and when you want to be observable over several types of events, you might want to keep
// pharos in a hashmap over type_id, and a derive would quickly become a mess.
//
impl Observable<GodessEvent> for Godess
impl Observable<GoddessEvent> for Goddess
{
fn observe( &mut self, options: ObserveConfig<GodessEvent>) -> Events<GodessEvent>
fn observe( &mut self, options: ObserveConfig<GoddessEvent>) -> Events<GoddessEvent>
{
self.pharos.observe( options )
}
Expand All @@ -158,7 +158,7 @@ fn main()
{
let program = async move
{
let mut isis = Godess::new();
let mut isis = Goddess::new();
// subscribe, the observe method takes options to let you choose:
// - channel type (bounded/unbounded)
Expand All @@ -178,7 +178,7 @@ fn main()
//
drop( isis );
assert_eq!( GodessEvent::Sailing, evt );
assert_eq!( GoddessEvent::Sailing, evt );
assert_eq!( None, events.next().await );
};
Expand Down Expand Up @@ -242,14 +242,14 @@ fn main()

## API

Api documentation can be found on [docs.rs](https://docs.rs/pharos).
API documentation can be found on [docs.rs](https://docs.rs/pharos).


## Contributing

This repository accepts contributions. Ideas, questions, feature requests and bug reports can be filed through github issues.
This repository accepts contributions. Ideas, questions, feature requests and bug reports can be filed through Github issues.

Pull Requests are welcome on github. By commiting pull requests, you accept that your code might be modified and reformatted to fit the project coding style or to improve the implementation. Please discuss what you want to see modified before filing a pull request if you don't want to be doing work that might be rejected.
Pull Requests are welcome on Github. By committing pull requests, you accept that your code might be modified and reformatted to fit the project coding style or to improve the implementation. Please discuss what you want to see modified before filing a pull request if you don't want to be doing work that might be rejected.


### Code of conduct
Expand Down
18 changes: 9 additions & 9 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ use

// here we put a pharos object on our struct
//
struct Godess { pharos: Pharos<GodessEvent> }
struct Goddess { pharos: Pharos<GoddessEvent> }


impl Godess
impl Goddess
{
fn new() -> Self
{
Self { pharos: Pharos::default() }
}

// Send Godess sailing so she can tweet about it!
// Send Goddess sailing so she can tweet about it!
//
pub async fn sail( &mut self )
{
self.pharos.notify( &GodessEvent::Sailing ).await;
self.pharos.notify( &GoddessEvent::Sailing ).await;
}
}

Expand All @@ -32,7 +32,7 @@ impl Godess
//
#[ derive( Clone, Debug, PartialEq, Copy ) ]
//
enum GodessEvent
enum GoddessEvent
{
Sailing
}
Expand All @@ -43,9 +43,9 @@ enum GodessEvent
// and when you want to be observable over several types of events, you might want to keep
// pharos in a hashmap over type_id, and a derive would quickly become a mess.
//
impl Observable<GodessEvent> for Godess
impl Observable<GoddessEvent> for Goddess
{
fn observe( &mut self, options: ObserveConfig<GodessEvent>) -> Events<GodessEvent>
fn observe( &mut self, options: ObserveConfig<GoddessEvent>) -> Events<GoddessEvent>
{
self.pharos.observe( options )
}
Expand All @@ -56,7 +56,7 @@ fn main()
{
let program = async move
{
let mut isis = Godess::new();
let mut isis = Goddess::new();

// subscribe, the observe method takes options to let you choose:
// - channel type (bounded/unbounded)
Expand All @@ -76,7 +76,7 @@ fn main()
//
drop( isis );

assert_eq!( GodessEvent::Sailing, evt );
assert_eq!( GoddessEvent::Sailing, evt );
assert_eq!( None, events.next().await );
};

Expand Down
4 changes: 2 additions & 2 deletions src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate :: { import::*, Filter, ObserveConfig, observable::Channel, Error };

/// A stream of events. This is returned from [Observable::observe](crate::Observable::observe).
///
/// For pharos 0.3.0 on x64 linux: `std::mem::size_of::<Events<_>>() == 16`
/// For pharos 0.3.0 on x64 Linux: `std::mem::size_of::<Events<_>>() == 16`
//
#[ derive( Debug ) ]
//
Expand Down Expand Up @@ -66,7 +66,7 @@ impl<Event> Stream for Events<Event> where Event: Clone + 'static + Send


/// The sender of the channel.
/// For pharos 0.3.0 on x64 linux: `std::mem::size_of::<Sender<_>>() == 56`
/// For pharos 0.3.0 on x64 Linux: `std::mem::size_of::<Sender<_>>() == 56`
//
#[ pin_project ]
//
Expand Down
2 changes: 1 addition & 1 deletion src/observable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub enum Channel
//
Bounded(usize),

/// A channel with unbounded capacity. Note that this may lead to unbouded memory consumption if producers
/// A channel with unbounded capacity. Note that this may lead to unbounded memory consumption if producers
/// outpace consumers.
//
Unbounded,
Expand Down
6 changes: 3 additions & 3 deletions src/pharos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate :: { import::*, Observable, Events, ObserveConfig, events::Sender };
/// they did not generate an error.
///
/// `join_all` will allocate a new vector on every notify from what our concurrent futures return. Ideally
/// we would use a datastructure which allows &mut access to individual elements, so we can work on them
/// we would use a data structure which allows &mut access to individual elements, so we can work on them
/// concurrently in place without reallocating. I am looking into the partitions crate, but that's for
/// the next release ;).
//
Expand All @@ -50,12 +50,12 @@ impl<Event> fmt::Debug for Pharos<Event> where Event: 'static + Clone + Send

impl<Event> Pharos<Event> where Event: 'static + Clone + Send
{
/// Create a new Pharos. May it's light guide you to safe harbour.
/// Create a new Pharos. May it's light guide you to safe harbor.
///
/// You can set the initial capacity of the vector of senders, if you know you will a lot of observers
/// it will save allocations by setting this to a higher number.
///
/// For pharos 0.3.0 on x64 linux: `std::mem::size_of::<Option<Sender<_>>>() == 56 bytes`.
/// For pharos 0.3.0 on x64 Linux: `std::mem::size_of::<Option<Sender<_>>>() == 56 bytes`.
//
pub fn new( capacity: usize ) -> Self
{
Expand Down
20 changes: 10 additions & 10 deletions tests/bounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn basic()
{
block_on( async move
{
let mut isis = Godess::new();
let mut isis = Goddess::new();
let mut events = isis.observe( Channel::Bounded( 5 ).into() );

isis.sail().await;
Expand All @@ -44,7 +44,7 @@ fn close_receiver()
{
block_on( async move
{
let mut isis = Godess::new();
let mut isis = Goddess::new();
let mut events = isis.observe( Channel::Bounded( 5 ).into() );

isis.sail().await;
Expand All @@ -65,7 +65,7 @@ fn one_receiver_drops()
{
block_on( async move
{
let mut isis = Godess::new();
let mut isis = Goddess::new();
let mut egypt_evts = isis.observe( Channel::Bounded( 1 ).into() );
let mut shine_evts = isis.observe( Channel::Bounded( 2 ).into() );

Expand Down Expand Up @@ -94,7 +94,7 @@ fn types()
{
block_on( async move
{
let mut isis = Godess::new();
let mut isis = Goddess::new();

// Note that because of the asserts below type inference works here and we don't have to
// put type annotation, but I do find it quite obscure and better to be explicit.
Expand Down Expand Up @@ -123,7 +123,7 @@ fn threads()
{
block_on( async move
{
let mut isis = Godess::new();
let mut isis = Goddess::new();
let mut egypt_evts = isis.observe( Channel::Bounded( 5 ).into() );
let mut shine_evts = isis.observe( Channel::Bounded( 5 ).into() );

Expand Down Expand Up @@ -165,7 +165,7 @@ fn block_sender()
let mut pool = LocalPool::new();
let mut exec = pool.spawner();
let mut isis = Godess::new();
let mut isis = Goddess::new();
let mut events: Receiver<IsisEvent> = isis.observe( 0 );
let sender = async move
Expand Down Expand Up @@ -202,7 +202,7 @@ fn filter()
{
block_on( async move
{
let mut isis = Godess::new();
let mut isis = Goddess::new();

let filter = |evt: &IsisEvent|
{
Expand Down Expand Up @@ -242,7 +242,7 @@ fn filter_true()
{
block_on( async move
{
let mut isis = Godess::new();
let mut isis = Goddess::new();

let filter = |_: &IsisEvent| true;

Expand Down Expand Up @@ -278,7 +278,7 @@ fn filter_false()
{
block_on( async move
{
let mut isis = Godess::new();
let mut isis = Goddess::new();

let filter = |_: &IsisEvent| false;

Expand Down Expand Up @@ -309,7 +309,7 @@ fn filter_move()
{
block_on( async move
{
let mut isis = Godess::new();
let mut isis = Goddess::new();
let v: Vec<u8> = Vec::new();

let filter = move |evt: &IsisEvent|
Expand Down
2 changes: 1 addition & 1 deletion tests/combined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn both()
{
block_on( async move
{
let mut isis = Godess::new();
let mut isis = Goddess::new();

let mut events: Events<IsisEvent> = isis.observe( Channel::Bounded( 5 ).into() );
let mut nuevts: Events<NutEvent> = isis.observe( Channel::Bounded( 5 ).into() );
Expand Down
8 changes: 4 additions & 4 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ pub mod import
use import::*;


pub struct Godess
pub struct Goddess
{
isis: Pharos<IsisEvent>,
nut : Pharos<NutEvent >,
}


impl Godess
impl Goddess
{
pub fn new() -> Self
{
Expand Down Expand Up @@ -79,7 +79,7 @@ pub struct NutEvent
}


impl Observable<IsisEvent> for Godess
impl Observable<IsisEvent> for Goddess
{
fn observe( &mut self, options: ObserveConfig<IsisEvent> ) -> Events<IsisEvent>
{
Expand All @@ -88,7 +88,7 @@ impl Observable<IsisEvent> for Godess
}


impl Observable<NutEvent> for Godess
impl Observable<NutEvent> for Goddess
{
fn observe( &mut self, options: ObserveConfig<NutEvent> ) -> Events<NutEvent>
{
Expand Down
Loading

0 comments on commit 10dcf85

Please sign in to comment.