Code Monkey home page Code Monkey logo

go-actor's People

Contributors

dependabot[bot] avatar vladopajic 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

go-actor's Issues

explore generic testing utilities

What are some generic tests which could benefit any Actor/Worker implementation?

Idea of this issue is to explore those possibilities and create those utilities if any.

Remote actors

Hello,

very interesting project. I would like to give it a try and build something on it but i have a question, it seems to me that currently remote actors with message passing through e.g. rpc are not supported, is that correct?

Blocking mailbox

So I was playing around with seeing if I can replicate the idea of a concurrent stream using the actor framework.
Consider the following code:

package main

import (
	"fmt"
	"os"
	"os/signal"
	"syscall"

	"github.com/vladopajic/go-actor/actor"
)

type OutStream actor.Actor

// outstream worker
type OutStreamWorker struct {
	mailbox actor.MailboxSender[string]
	doFunc  func() (string, bool)
}

func (w OutStreamWorker) DoWork(c actor.Context) actor.WorkerStatus {
	val, ok := w.doFunc()
	if ok {
		w.mailbox.Send(c, val)
		return actor.WorkerContinue
	}
	return actor.WorkerEnd
}

func NewOutStream(f func() (string, bool)) (OutStream, actor.Mailbox[string]) {
	mailbox := actor.NewMailbox[string]()
	worker := OutStreamWorker{
		mailbox: mailbox,
		doFunc:  f,
	}
	actor := actor.New(worker)
	return actor, mailbox
}

type strIter struct {
	slice  []string
	cursor int
}

func (i *strIter) Next() (string, bool) {
	if i.cursor < len(i.slice) {
		val := i.slice[i.cursor]
		i.cursor++
		return val, true
	} else {
		return "", false
	}
}

func main() {
	iter := strIter{
		slice:  []string{"A", "B", "C"},
		cursor: 0,
	}

	stream, mailbox := NewOutStream(iter.Next)
	stream.Start()

	for v := range mailbox.ReceiveC() {
		fmt.Println(v)
	}
}

The idea is the following: I create a stateful iterator with a .Next method, and then create an OutStream (which is just an actor) whose worker just takes the iterator and calls the .Next method and puts the results on the out mailbox. Then at the other end of the mailbox I just want to loop over the channel and print the results.
The above code blocks at w.mailbox.Send in the DoWork function, but my understanding was that mailbox should not block, any thoughts? :)

Re-License to MIT, BSD, or ASLv2?

It looks like a lot of work went into this project, I'd love to be able to use it, and see other projects use it, too. Unfortunately, it's difficult to do so given the GPLv2 licensing. Would you consider relicensing the project under a permissive license such as the MIT, BSD, or Apache Software License?

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.