Giter VIP home page Giter VIP logo

fszmq's Introduction

fszmq


ATTENTION!

This repository has been archived and is no longer being maintained. For a suitable replacement, please consider: https://github.com/zeromq/netmq


An F# binding for the ZeroMQ distributed computing library.

fszmq is an MPLv2-licensed F# binding for the ZeroMQ distributed computing library. It provides a complete binding to versions 2.1.x, 3.2.x, 4.0.x, 4.1.x of ZeroMQ (Note: prior to 4.0.0, each binding is a separate branch in git, as there are some non-compatible differences). This library is primarily designed to be consumed from F#. However, where possible, the library has been designed to appear "friendly" when consumed by other CLR languages (C#, et aliam).


NuGet

The fszmq library can be installed from NuGet:

PM> Install-Package fszmq

Please note: the fszmq NuGet package ONLY provides the managed fszmq.dll file. You need to provide the native libzmq file(s) appropriate to your platform.


Acquiring libzmq

On Windows, the recommended solution is to download a release from the official GitHub repo and then compile it in a recent version of Visual Studio (several versions are supported... check the release docs for more information).

On macOS, the recommended solution is to install zmq from Homebrew -- the missing package manager.

On Linux, the recommended solution is install libzmq from your distro's package manager. Alternatively, you may build from source.

Please note: in a pinch, the lib folder in the root of this repo contains Windows, macOS, and Linux binaries of libzmq. But they're not compiled with all available features for all platforms and may not behave as expected.

Platforms

At this point in time, fszmq has been tested on the following platform/architecture/runtime combinations:

  • 32-bit Windows XP (running against .NET Framework)
  • 64-bit Windows Server 2008 R2 (running against .NET Framework)
  • 32-bit and 64-bit Windows 7 (running against .NET Framework or Mono)
  • 32-bit and 64-bit Windows 8 (running against .NET Framework or Mono)
  • 32-bit and 64-bit Windows 10 (running against .NET Framework, .NET Core, and Mono)
  • 32-bit and 64-bit OS X (running against Mono)
  • 64-bit Linux (Ubuntu 18.04 running against .NET Core)

Other platform/architecture/runtime combinations should work (so long as .NET Framework, .NET Core, or Mono are supported and there is a native libzmq port).


IMPORTANT NOTE: starting with version 12.3, fszmq will only ship as a .NET Standard library (currently, .NET Standard 2). This may have consequences (or limitations) for existing applications wishing to upgrade.


A note about versions

In the past, several attempts were made (poorly) to keep the version of fszmq synchronized to the version of libzmq. Starting with verion 12.0.0 (which is the twelth release... version 4.0.9 was the eleventh release), this is no longer done. Instead, fszmq is versioned independently. The versions of libzmq supported by each version of fszmq are as follows (where 'x' means any number >= 0):

fszmq version libzmq versions supported
12.3.x 4.1.x (and a sub-set of 4.2.x)
12.2.x 4.1.x
12.1.1 4.1.x
12.1.0 4.1.x
12.0.1 4.0.x
4.0.9 4.0.5
4.0.8 4.0.5
4.0.6 4.0.5
4.0.5 4.0.5
4.0.4 4.0.4
3.2.7 3.2.5
3.2.5 3.2.5
2.2.1 2.2.1
2.2.0 2.2.0
2.1.11 2.1.x
2.1.10 2.1.x
2.1.6 2.1.x

More information about ZeroMQ is available at http://zero.mq.

Issues, questions, and concerns may be directed the the Issue Tracker.

If you'd like to help develop and maintain fszmq, please read about CONTRIBUTING.


This project is released under the MPL (v2) license.
This project's documentation is released under the MIT license.

fszmq's People

Contributors

c-rack avatar coconaut avatar danielfabian avatar haf avatar hammett avatar hintjens avatar nrolland avatar pblasucci avatar petvetbr avatar sergey-tihon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fszmq's Issues

basedirectories is not defined

when starting from a fresh clone, we get the error message in the title.
is there a specific version of Fake to use ?

Explain Versioning System

fszmq has been updated to use a four-segment versioning scheme. This needs to be explained (in docs? in root README.md).

Review the Equality and Comparison Semantics for Core Types

Currently, as constructed classes, the three core types (Context, Socket, and Message) use the CLR's default equality and comparison semantics. An analysis should be performed to determine the correct semantics. Possible options include:

  • Referential equality based on Handle
  • Structural equality based on Handle
  • Structural equality based on select properties (e.g. message content, socket type)
  • Equality without comparison

Create API documents

Need up-to-date reference documentation for the full fszmq API. This should display well in both VS Intellisense and via FSharp.Formatting (i.e. XMLDoc and Markdown need to be mixed surgically).

Question: How did you build the libzmq.dll under windows?

I try to build zeromq but it fails

$ git clone -s https://github.com/zeromq/zeromq4-x
$ cd zeromq4-x
$ ./configure --build=i686-pc-mingw32 --host=i686-pc-mingw32
$ make
Making all in src
make[1]: Entering directory '/e/0MQ/zeromq4-x/src'
make all-am
make[2]: Entering directory '/e/0MQ/zeromq4-x/src'
CXX libzmq_la-address.lo
In file included from err.hpp:40:0,
from address.cpp:21:
windows.hpp:168:21: fatal error: Mstcpip.h: No such file or directory
compilation terminated.
Makefile:746: recipe for target 'libzmq_la-address.lo' failed
make[2]: *** [libzmq_la-address.lo] Error 1
make[2]: Leaving directory '/e/0MQ/zeromq4-x/src'
Makefile:560: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/e/0MQ/zeromq4-x/src'
Makefile:412: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

How did you manage to build the libzmq.dll?

Add tests for Z85 encdoing

Need more tests, both passing and failing, for the following functions of the Z85 module:

  • encode : byte[] -> string
  • decode : string -> byte[]

Include Security API

Master branch needs to fully support the new security features in libzmq v4.0.x. Minimally, this means:

  • supported socket options
  • utility functions (keygen, encode, decode)

Additional Utility Functions

Review zmq.h and zmq_util.h (in libzmq) and zhelpers.h (part of zguide) to determine if fszmq could benefit from any helper functionality.

Explain Documentation Licensing

Somewhere (probably READ.md and Index.fsx) add a note about the documenation being MIT-licensed (as opposed to the source and tests, which are LGPL-licensed).

Performance Tune P/Invoke

Assess impact of the following:

  • using SetLastError=false with P/Invoke calls
  • relax CodeAccessSecurity
  • let libzmq do more high-level (i.e. multi-part message) processing

mono pb

the declaration [<MarshalAs(UnmanagedType.AnsiBStr)>]
in

[<DllImport("libzmq",CallingConvention = CallingConvention.Cdecl)>]
  extern int zmq_bind(HANDLE socket,
                      [<MarshalAs(UnmanagedType.AnsiBStr)>] 
                      string address)

and the like, makes mono crash with the following error

mono helloworld.exe                                                                           ✱ ◼

Unhandled Exception:
System.Runtime.InteropServices.MarshalDirectiveException: string marshalling conversion 35 not implemented
  at (wrapper managed-to-native) fszmq.C:zmq_bind (intptr,string)
  at fszmq.SocketModule.Bind (fszmq.Socket socket, System.String address) [0x00000] in <filename unknown>:0
  at Program.server (System.Object state) [0x00000] in <filename unknown>:0
  at [email protected] (System.Object obj) [0x00000] in <filename unknown>:0
  at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Runtime.InteropServices.MarshalDirectiveException: string marshalling conversion 35 not implemented

If I remove such directive, it seems to work :

mono helloworld.exe                                                                         ⏎ ✱ ◼
Connecting to hello world server...
Sending Hello 0...
Received Hello
Received World 0
Sending Hello 1...
Received Hello
Received World 1
Sending Hello 2...
Received Hello

I am not sure what are those for .

Create Narrative Documents

Code base needs narrative-style sample docs (built using FSharp.Formatting). At a minimum need:

  • getting started
  • "hello, world", for each MEP

Change Coding Standards

  • Extend line-wrap to 120 characters
  • Review public API member names
  • Include assertions where necessary

Modify build process to support multiple architectures

The build process should compile, test, and package both x86 and x64 variants of fszmq.dll (actually, fszmq.dll and associated unit tests are AnyCPU, but the underlying libzmq.dll architecture needs to match that of the test runner). This will probably require multiple NuGet packages, unless something clever can be done from the Install.ps1 script.

See also issue #27.

Add small graphic to API docs

Maybe embedded a small variant of the library's logo graphic on the API documentation and non-home-page narrative documentation.

Create Example Documentation

Code base needs narrative-style sample docs (built using FSharp.Formatting).

At a minimum need:

  • getting started
  • "hello, world" -- for each MEP

Note: Attempt to connect narrative documentation to zguide samples.

Determine Correctness of EAGAIN

Currently, EAGAIN is hard-coded to 11. This is most likely wrong. Figure out the correct (per-platfrom) values and adjust.

Implement Socket Monitor API

Master branch needs to support the Socket Monitor functionality. However, it should do show in a more elegant and obvious way than was implemented in the 3.2.7 branch. Consider doing something with events/observables or, at least, callbacks.

More Sophisticated AssemblyInfo Generation

The current process for generating AssemblyInfo (default mechanism is FAKE) is sub-optimal for the following reasons:

  • rewrites the entire file each time
  • does not allow fine-brained control of emitted output

Either extend existing build task or devise a new (template-based?) build task. Ultimately, it would be great to store the most-recently generated variant of this file in source control (as a bit of a sanity check).

Update License to LGPLv3

Currently, the source is Apache-licensed. This should be changed to LGPLv3, which requires:

  • determine if any special clauses need to be added
  • update root LICENSE.txt file
  • update header a-top each source file

NOTE: narrative docs and samples should be MIT/X11-licensed.

Determine Utility of Socket-level Send/Recv

libzmq exposes zmq_send and zmq_recv, which overlap with zmq_msg_send and zmq_msg_recv (respectively). Perform gap analysis and determine whether or not to expose all for functions.

xUnit runner sometimes crashes

Seems to occur on back-to-back runs. Possibly killing instance after each run will fix. Also happens in VS2012/VS2013 test runner.

Add support for PLAIN security mechanism

Add support for PLAIN security mechanism as described in the RFC.

At a very high level, this means adding some new socket options and verifying the overall workflow. However, it might be nice to layer a convenience API on top of this functionality.

Implementation of Dispose is not accessible without casting

Message, Socket, and Context implement IDisposable, but their Dispose methods are not public. Calling Dispose from C# requires casting the object to IDisposable. Is there a reason for this, or can the accessibility be changed to make usage cleaner?

Clean-up Functions and Options

Weed out unused (and, where possible, deprecated) functions and options, while ensuring new options are supported, and that all option names make sense.

Add Compatiblity Tests

Ensure optimal experience from C# and VB.NET. But "tests" aren't really the right mechanism. Maybe find a better term/methodology?

Consider shipping multiple NuGet packages.

Possibly three packages:

Variant File Platform
fszmq.x86.nupkg
fszmq.dll AnyCPU
libzmq.dll x86
fszmq.x64.nupkg
fszmq.dll AnyCPU
libzmq.dll x64
fszmq.nupkg
fszmq.dll AnyCPU
(no native library)

As an alternative, just ship fszmq.dll -- and let the consumer worry about libzmq.dll.


NOTE: this doesn't even account for variations around OpenMP, Sodium, or anything else against which ZeroMQ might be optionally compiled.

Create Library Documentation

Need up-to-date reference documentation for the full fszmq API. This should display well in both VS Intellisense and via FSharp.Formatting (i.e. XMLDoc and Markdown need to be mixed surgically).

Cannot dispose Context cleanly

I cannot dispose a REP server cleanly. The code:

let ctx = new Context()
let c = Context.req ctx
Socket.setOption c (ZMQ.LINGER, 0) // the socket should close instantly 
Socket.connect c "tcp://localhost:5555"

// Some if no exceptions, None if there're
let recv socket =
    try Some (Socket.recv socket) 
    with e -> printfn "Exn on recv: %A" e; None

let rec client() = async {
    Socket.send c (Encoding.UTF8.GetBytes "Hello!")
    match recv c with
    | Some msg -> return! client()
    | None -> printfn "Loop finished." }

Async.Start (client())

Console.ReadKey() |> ignore
printf "Disposing socket..."
(c :> IDisposable).Dispose()
printfn "done."
printf "Disposing context..."
try (ctx :> IDisposable).Dispose() with e -> printfn "Exn on context dispose: %A" e
printfn "done."
printfn "The end."

I run the console, wait for some seconds, then press any key. It says me the following:

Disposing socket...done.
Disposing context...Exn on recv: System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
   at fszmq.C.zmq_msg_recv(IntPtr msg, IntPtr socket, Int32 flags)
   at fszmq.SocketModule.Recv(Socket socket)
   at [email protected](Socket socket) in L:\git\ZeroMqTest2\ZmqTest.Server\Program.fs:line 15
Loop finished.

So, the recv has caught the exception and finished as expected. But the Context has hung forever (as we've not got "done. The end." message).
I just wonder if it's a bug or I do things in a wrong way/order?

Add facade to improving framing

It might be nice to have a higher-level way of assembling multi-part messages. Some ideas to play with:

  1. Union for composing chain of frames
  2. Collection type for manipulating frames in batches
  3. Extension methods and/or pipe-friendly functions for fluent API
  4. Predefine common control sequences (e.g. non-printing ASCII)

Support x32 and x64 simultaneously in Nuget

It's possible to choose the native DLL that is loaded at runtime. That allows us to have a single Nuget package that includes both x86 and x64 support. Once the native DLL is loaded, all DllImport items use that one. This also allows the nice "Any CPU" support. You can see how this is done with Sqlite (on Windows):

[DllImport("kernel32", SetLastError = true)]
public static extern IntPtr LoadLibrary(string lpFileName);

static MyClassThatUsesTheNativeLibrary()
{
LoadLibrary(Path.Combine(IntPtr.Size > 4 ? "x64" : "x32", "Sqlite.Interop.dll"));
}

Installing nuget errors out

Says cannot convert System.Int32 to ProjectBuildAction. Going to use something similar to what SQLite does; it uses 1 (not 2 like I am in the nuget)

Add Unit Tests

All public API functionality should have test coverage (possibly include random testing).

Implement Message API

Update message-level functionality to be consistent with libzmq and overall fszmq design:

  • rename Frame class to Message
  • create Message module
  • expose low-level zmq_msg_* methods

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.