Giter Club home page Giter Club logo

hunt's Introduction

Build Status

Hunt library

A refined core library for D programming language.

Modules

  • hunt.event
  • hunt.io
  • hunt.logging
  • hunt.util

Platforms

  • FreeBSD
  • Windows
  • macOS
  • Linux
  • Android

Libraries

  • hunt-net – An asynchronous event-driven network library written in D.

Frameworks

  • hunt-framework – Hunt is a high-level D Programming Language Web framework that encourages rapid development and clean, pragmatic design. It lets you build high-performance Web applications quickly and easily.

Requirements

D Compiler 2.088+.

Avaliable versions

Identifier Description
HUNT_DEBUG Used to log some debug messages

Benchmarks

Benchmark

For details, see here.

Thanks

  • @Cogitri
  • @deviator
  • @jasonwhite
  • @Kripth
  • @n8sh
  • @shove70

TODO

  • Better performance
  • Better APIs
  • Improvement for Worker with IOCP

hunt's People

Contributors

baryluk avatar cenan avatar cogitri avatar dushibaiyu avatar gaoxincheng avatar geod24 avatar heromyth avatar jasonsalex avatar kubo39 avatar n8sh avatar noclear avatar shove70 avatar stevenpan110 avatar wangyun0831 avatar xiaoshuaisen avatar yilabs avatar zhangyuchun avatar zoujiaqing 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hunt's Issues

The new copyright information for 2019.

/*
 * Hunt - A refined core library for D programming language.
 *
 * Copyright (C) 2018-2019 HuntLabs
 *
 * Website: https://www.huntlabs.net/
 *
 * Licensed under the Apache-2.0 License.
 *
 */

TcpStream._writeQueue new when used.

Hi @Heromyth :

if (_writeQueue.isEmpty() && !_isWritting) {

Sample code:

if (_writeQueue is null && !_isWritting)
{
    // You don't need to change the code here
}
else
{
    initializeWriteQueue();
    write(new SocketStreamBuffer(data, handler));
}

void initializeWriteQueue()
{
    if (_writeQueue is null)
    {
        _writeQueue = new WritingBufferQueue();
    }
}

咨询几个问题

  1. 这个lib的API文档有吗?好像文档都没有,要去看源代码。。。
  2. 能否增加一个模块,就是GBK和UTF8的互转,这个功能D里面不支持。

cant run example on OSX

Hello,
Can't run example on OSX:

Performing "debug" build using /Library/D/dmd/bin/dmd for x86_64.
kiss 0.4.8+commit.3.g2f367e4: target for configuration "debug" is up to date.
tcp-client ~master: building configuration "application"...
Linking...
To force a rebuild of up-to-date targets, run again with --force.
Running ./tcp-client 
2018-08-02 12:02:12 (2368576) [debug] this - Buffer size for read: 8192 - ../../source/kiss/event/socket/posix.d:87
2018-08-02 12:02:12 (2368576) [debug] socket - new socket fd: cast(socket_t)6 - ../../source/kiss/event/socket/common.d:150
2018-08-02 12:02:12 (2368576) [debug] onWrite - start to write - ../../source/kiss/net/TcpStream.d:248
2018-08-02 12:02:12 (2368576) [debug] onWrite - writting... - ../../source/kiss/net/TcpStream.d:253
2018-08-02 12:02:12 (2368576) [debug] tryWrite - actually sent bytes: -1 / 12 - ../../source/kiss/event/socket/posix.d:232
2018-08-02 12:02:12 (2368576) [warning] tryWrite - errno=32, message: Broken pipe - ../../source/kiss/event/socket/posix.d:241
2018-08-02 12:02:12 (2368576) [error] onWrite - Socket error on write: fd=6, message=Broken pipe - ../../source/kiss/net/TcpStream.d:277
2018-08-02 12:02:12 (2368576) [debug] close - channel closing... - ../../source/kiss/event/core.d:168
2018-08-02 12:02:12 (2368576) [warning] onClose - Some data has not been sent yet. - ../../source/kiss/net/TcpStream.d:219
The connection is closed!
2018-08-02 12:02:12 (2368576) [debug] close - channel closed... - ../../source/kiss/event/core.d:171
2018-08-02 12:02:12 (2368576) [warning] close - The watcher(fd=6) has already been closed - ../../source/kiss/event/core.d:175
core.exception.InvalidMemoryOperationError@src/core/exception.d(700): Invalid memory operation
----------------
Program exited with code 1

There may be bugs in Radix tree.

On MacOS, There may be bugs in Radix tree.

import std.stdio;

import core.stdc.stdlib;
import core.stdc.string;

import hunt.collection.Radix;

void main()
{
	byte[] data = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];
	ubyte[] key = cast(ubyte[])"A key";

	void *value = malloc(data.length + 4);
	uint len = cast(uint)data.length;
	memcpy(value, &len, 4);
	memcpy(value + 4, data.ptr, data.length);

	rax *r;
	r = rax.New();
	writeln("Insert: ", r.Insert(key, value));


	void *read;
	if (!r.find(key, read))
	{
	    writeln("Not found.");
	    return;
	}

	memcpy(&len, read, 4);
	data = new byte[len];
	memcpy(data.ptr, read + 4, len);
	writeln(data);
	
	r.Remove(key);
	rax.Free(r);
}

Using this code to test, run it several times, and you will get different results:

1:
Running ./hunttest_radix
Insert: 1
Not found.
2:
Running ./hunttest_radix
Insert: 1
[1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]
(Program does not exit, there is a dead cycle...)
3:
Running ./hunttest_radix
Insert: 1
[1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Program exited with code -11
4:
Running ./hunttest_radix
Insert: 1
[1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]
(Normal end as expected)

Radix has a problem that prevents hunt-framework from working properly.

Broadcast UDP

In example highlights a problem: doesn't work if use 255.255.255.255 addr.
Will it be fixed?

Timer always runs every 1 second

It seems that the KissTimer in package kiss.util.timer always runs every 1 second, regardless of the Duration passed to the constructor.

I have tested on Windows 10 with the following program:

import std.datetime : StopWatch, seconds;
import std.stdio : writeln;
import kiss.event : EventLoop;
import kiss.util.timer : KissTimer;

EventLoop eventLoop = new EventLoop();

StopWatch watch = StopWatch();
watch.start();

KissTimer timer = new KissTimer(eventLoop, 10.seconds);
timer.onTick((Object sender){ writeln(watch.peek.msecs); });
timer.start();

eventLoop.run();

Consider breaking out concurrency library into a standalone project

Hi,

I get the impression that you have ported OpenJDK code in many places ... this has potential IP issues. Firstly you should probably retain the OpenJDK copyright - and that implies GPL plus Classpath exception. But please be aware of potential IP issues.

The concurrency libraries however can be based on Doug Lea's version which is in the public domain. I suggest breaking out the concurrency library so that it is not tainted by Oracle IP.

Regards

Configuration support array

test.conf

server.addreses = 127.0.0.1:8080
server.addreses = 127.0.0.1:9090

D Code:

class ServerConf
{
    string addresses[];
}

hunt-1.0.0-rc.3 doesn't compile on windows


hunt 1.0.0-rc.3: building configuration "library"...
C:\Users\Mark\AppData\Local\dub\packages\hunt-1.0.0-rc.3\hunt\source\hunt\event\selector\iocp.d(192,10): Error: cannot implicitly override base class method `hunt.event.core.Selector.dispose` with `hunt.event.selector.iocp.AbstractSelector.dispose`; add `override` attribute
C:\Users\Mark\AppData\Local\dub\packages\hunt-1.0.0-rc.3\hunt\source\hunt\event\EventLoop.d(38,19): Error: function `hunt.event.EventLoop.EventLoop.stop` does not override any function
C:\d\dmd2\windows\bin\dmd.exe failed with exit code 1.
~

and after adding the override attribute:


hunt 1.0.0-rc.3: building configuration "library"...
C:\Users\Mark\AppData\Local\dub\packages\hunt-1.0.0-rc.3\hunt\source\hunt\event\EventLoopGroup.d(28,25): Error: cannot create instance of abstract class `EventLoop`
C:\Users\Mark\AppData\Local\dub\packages\hunt-1.0.0-rc.3\hunt\source\hunt\event\EventLoopGroup.d(28,25):        function `int doSelect(long timeout)` is not implemented
C:\d\dmd2\windows\bin\dmd.exe failed with exit code 1.

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.