From 61a56fd89c0b25039000ddc40baacea40a05ead0 Mon Sep 17 00:00:00 2001 From: Chris Constantin Date: Tue, 10 May 2016 13:04:54 -0700 Subject: [PATCH] Initial API release --- .gitattributes | 29 +++ .gitignore | 201 ++++++++++++++++++ CopyrightWaivers.txt | 1 + README.md | 10 +- src/Reactive.Streams.sln | 22 ++ src/Reactive.Streams/IProcessor.cs | 20 ++ src/Reactive.Streams/IPublisher.cs | 77 +++++++ src/Reactive.Streams/ISubscriber.cs | 103 +++++++++ src/Reactive.Streams/ISubscription.cs | 50 +++++ .../Properties/AssemblyInfo.cs | 26 +++ src/Reactive.Streams/Reactive.Streams.csproj | 56 +++++ src/Reactive.Streams/Reactive.Streams.nuspec | 16 ++ 12 files changed, 606 insertions(+), 5 deletions(-) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 src/Reactive.Streams.sln create mode 100644 src/Reactive.Streams/IProcessor.cs create mode 100644 src/Reactive.Streams/IPublisher.cs create mode 100644 src/Reactive.Streams/ISubscriber.cs create mode 100644 src/Reactive.Streams/ISubscription.cs create mode 100644 src/Reactive.Streams/Properties/AssemblyInfo.cs create mode 100644 src/Reactive.Streams/Reactive.Streams.csproj create mode 100644 src/Reactive.Streams/Reactive.Streams.nuspec diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..b55fe50 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,29 @@ +# Auto detect text files and perform LF normalization +* text=auto + + +# Custom for Visual Studio +*.cs diff=csharp +*.sln merge=union +*.csproj merge=union +*.vbproj merge=union +*.fsproj merge=union +*.dbproj merge=union + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain + +# Needed for Mono build shell script +*.sh -text eol=lf + +# Needed for API Approvals +*.txt text eol=crlf \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..67e5455 --- /dev/null +++ b/.gitignore @@ -0,0 +1,201 @@ + +#GitExtensions +us.stackdump + +#KDiff3 and other git merge tools +*.orig + +#------------------------------------------------------------------------------- +#Based on https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +#MonoDevelop +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Roslyn cache directories +*.ide/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NBench results +[Pp]erf[Rr]esult*/ + +#NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding addin-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +*.ncrunchsolution +*.v2.ncrunchproject + + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment out the next line if you want to keep your passwords hidden +*.pubxml + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# If using the old MSBuild-Integrated Package Restore, uncomment this: +!**/packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# make exception for Akka.Persistence.SqlServer database file +!AkkaPersistenceSqlServerSpecDb.mdf +!AkkaPersistenceSqlServerSpecDb_log.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings \ No newline at end of file diff --git a/CopyrightWaivers.txt b/CopyrightWaivers.txt index f17e16c..85606e1 100644 --- a/CopyrightWaivers.txt +++ b/CopyrightWaivers.txt @@ -18,3 +18,4 @@ Underwriting parties: github name | Real Name, Email Address used for git commits, Company ---------------+---------------------------------------------------------------------------- +cconstantin | Chris Constantin, chris.constantin@aligned.io, Aligned Software Solutions, Inc. \ No newline at end of file diff --git a/README.md b/README.md index 8c5f6b6..8ac904b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# Reactive Streams .NET# - -The purpose of Reactive Streams is to provide a standard for asynchronous stream processing with non-blocking backpressure. - -For now, see the details for the (JVM)[https://github.com/reactive-streams/reactive-streams-jvm/blob/master/README.md]. +# Reactive Streams .NET# + +The purpose of Reactive Streams is to provide a standard for asynchronous stream processing with non-blocking backpressure. + +For now, see the details for the [JVM](https://github.com/reactive-streams/reactive-streams-jvm/blob/master/README.md). diff --git a/src/Reactive.Streams.sln b/src/Reactive.Streams.sln new file mode 100644 index 0000000..92cdfb8 --- /dev/null +++ b/src/Reactive.Streams.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25123.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Reactive.Streams", "Reactive.Streams\Reactive.Streams.csproj", "{68FBB4DF-6D83-4CF1-8105-A1D41912852F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {68FBB4DF-6D83-4CF1-8105-A1D41912852F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {68FBB4DF-6D83-4CF1-8105-A1D41912852F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {68FBB4DF-6D83-4CF1-8105-A1D41912852F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {68FBB4DF-6D83-4CF1-8105-A1D41912852F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/Reactive.Streams/IProcessor.cs b/src/Reactive.Streams/IProcessor.cs new file mode 100644 index 0000000..c5ae936 --- /dev/null +++ b/src/Reactive.Streams/IProcessor.cs @@ -0,0 +1,20 @@ +namespace Reactive.Streams +{ + /// + /// A Processor represents a processing stage—which is both a + /// and a and obeys the contracts of both. + /// + public interface IProcessor : ISubscriber, IPublisher + { + } + + /// + /// A Processor represents a processing stage—which is both a + /// and a and obeys the contracts of both. + /// + /// The type of element signaled to the + /// The type of element signaled to the + public interface IProcessor : IProcessor, ISubscriber, IPublisher + { + } +} \ No newline at end of file diff --git a/src/Reactive.Streams/IPublisher.cs b/src/Reactive.Streams/IPublisher.cs new file mode 100644 index 0000000..a5a199d --- /dev/null +++ b/src/Reactive.Streams/IPublisher.cs @@ -0,0 +1,77 @@ +namespace Reactive.Streams +{ + /// + /// + /// A is a provider of a potentially unbounded number of sequenced elements, + /// publishing them according to the demand received from its . + /// + /// + /// A can serve multiple s subscribed dynamically + /// at various points in time. + /// + /// + public interface IPublisher + { + /// + /// + /// Request to start streaming data. + /// + /// + /// This is a "factory method" and can be called multiple times, each time starting a new + /// . + /// + /// + /// Each will work for only a single . + /// + /// + /// A should only subscribe once to a single + /// . + /// + /// + /// If the rejects the subscription attempt or otherwise fails + /// it will signal the error via . + /// + /// + /// The that will consume signals + /// from this + void Subscribe(ISubscriber subscriber); + } + + /// + /// + /// A is a provider of a potentially unbounded number of sequenced elements, + /// publishing them according to the demand received from its . + /// + /// + /// A can serve multiple s subscribed dynamically + /// at various points in time. + /// + /// + /// The type of element signaled. + public interface IPublisher : IPublisher + { + /// + /// + /// Request to start streaming data. + /// + /// + /// This is a "factory method" and can be called multiple times, each time starting a new + /// . + /// + /// + /// Each will work for only a single . + /// + /// + /// A should only subscribe once to a single + /// . + /// + /// + /// If the rejects the subscription attempt or otherwise fails + /// it will signal the error via . + /// + /// + /// The that will consume signals + /// from this + void Subscribe(ISubscriber subscriber); + } +} \ No newline at end of file diff --git a/src/Reactive.Streams/ISubscriber.cs b/src/Reactive.Streams/ISubscriber.cs new file mode 100644 index 0000000..2e1886c --- /dev/null +++ b/src/Reactive.Streams/ISubscriber.cs @@ -0,0 +1,103 @@ +using System; + +namespace Reactive.Streams +{ + /// + /// + /// Will receive call to once after passing an instance of + /// to . + /// + /// + /// No further notifications will be received until is called. + /// + /// After signaling demand: + /// 1. One or more invocations of up to the maximum number defined by + /// + /// 2. Single invocation of or which signals + /// a terminal state after which no further events will be sent. + /// + /// Demand can be signaled via whenever the + /// instance is capable of handling more. + /// + public interface ISubscriber + { + /// + /// + /// Invoked after calling . + /// + /// + /// No data will start flowing until is invoked. + /// + /// + /// It is the responsibility of this instance to call + /// whenever more data is wanted. + /// + /// + /// The will send notifications only in response to + /// . + /// + /// + /// that allows requesting data + /// via + void OnSubscribe(ISubscription subscription); + + /// + /// Data notification sent by the in response to requests to + /// . + /// + /// The element signaled + void OnNext(object element); + + /// + /// + /// Failed terminal state. + /// + /// + /// No further events will be sent even if is + /// invoked again. + /// + /// + /// The exception signaled + void OnError(Exception cause); + + /// + /// + /// Successful terminal state. + /// + /// + /// No further events will be sent even if is + /// invoked again. + /// + /// + void OnComplete(); + } + + /// + /// + /// Will receive call to once after passing an instance of + /// to . + /// + /// + /// No further notifications will be received until is called. + /// + /// After signaling demand: + /// 1. One or more invocations of up to the maximum number defined by + /// + /// 2. Single invocation of or + /// which signals a terminal state after which no further + /// events will be sent. + /// + /// Demand can be signaled via whenever the + /// instance is capable of handling more. + /// + /// The type of element signaled. + public interface ISubscriber : ISubscriber + { + /// + /// Data notification sent by the in response to requests to + /// . + /// + /// The element signaled + void OnNext(T element); + } +} \ No newline at end of file diff --git a/src/Reactive.Streams/ISubscription.cs b/src/Reactive.Streams/ISubscription.cs new file mode 100644 index 0000000..8cbc1b8 --- /dev/null +++ b/src/Reactive.Streams/ISubscription.cs @@ -0,0 +1,50 @@ +namespace Reactive.Streams +{ + /// + /// + /// A represents a one-to-one lifecycle of a + /// subscribing to a . + /// + /// + /// It can only be used once by a single . + /// + /// + /// It is used to both signal desire for data and cancel demand (and allow resource cleanup). + /// + /// + public interface ISubscription + { + /// + /// + /// No events will be sent by a until demand is signaled via this method. + /// + /// + /// It can be called however often and whenever needed—but the outstanding cumulative demand + /// must never exceed . + /// An outstanding cumulative demand of may be treated by the + /// as "effectively unbounded". + /// + /// + /// Whatever has been requested can be sent by the so only signal demand + /// for what can be safely handled. + /// + /// + /// A can send less than is requested if the stream ends but + /// then must emit either or . + /// + /// + /// The strictly positive number of elements to requests to the upstream + /// + void Request(long n); + + /// + /// + /// Request the to stop sending data and clean up resources. + /// + /// + /// Data may still be sent to meet previously signalled demand after calling cancel as this request is asynchronous. + /// + /// + void Cancel(); + } +} diff --git a/src/Reactive.Streams/Properties/AssemblyInfo.cs b/src/Reactive.Streams/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1661a65 --- /dev/null +++ b/src/Reactive.Streams/Properties/AssemblyInfo.cs @@ -0,0 +1,26 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Reactive.Streams")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyProduct("Reactive.Streams")] +[assembly: AssemblyCulture("")] + +[assembly: AssemblyCompany("Reactive Streams")] +[assembly: AssemblyCopyright("Licensed under Public Domain (CC0)")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("68fbb4df-6d83-4cf1-8105-a1d41912852f")] \ No newline at end of file diff --git a/src/Reactive.Streams/Reactive.Streams.csproj b/src/Reactive.Streams/Reactive.Streams.csproj new file mode 100644 index 0000000..bf7c22b --- /dev/null +++ b/src/Reactive.Streams/Reactive.Streams.csproj @@ -0,0 +1,56 @@ + + + + + Debug + AnyCPU + {68FBB4DF-6D83-4CF1-8105-A1D41912852F} + Library + Properties + Reactive.Streams + Reactive.Streams + v4.0 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Reactive.Streams/Reactive.Streams.nuspec b/src/Reactive.Streams/Reactive.Streams.nuspec new file mode 100644 index 0000000..b34b229 --- /dev/null +++ b/src/Reactive.Streams/Reactive.Streams.nuspec @@ -0,0 +1,16 @@ + + + + $id$ + $id$ + $version$ + $author$ + $author$ + Reactive Streams API + http://creativecommons.org/publicdomain/zero/1.0/ + https://github.com/reactive-streams/reactive-streams-dotnet + false + CC0 1.0 Universal + reactive stream + +