Code Monkey home page Code Monkey logo

queen-core's Introduction

queen-core(WIP)

用 vue 的方式写服务端,并且自带多线程 rpc等功能

Hooks

生命周期函数

export default {
    hooks:{
        start()
        {
            console.log("ant.start",this.$ant.template)

            this.$ant.setTimeout(console.log,5000,"timeout timer")
        },
        stop()
        {
            console.log("ant.stop",this.$ant.template)
        }
    },
}

定时器

系统自动注册定时器实现

export default {
    data()
    {
        return {
            count:0
        }
    },
    hooks:{
        start()
        {
            this.$ant.setTimeout(console.log,5000,"timeout timer")
        },
    },
    timers:{
        "1s": {
            interval: 1000,
            handler()
            {
                console.log("1s", ++this.count)
            }
        }
    }
}

概念

  • Application:系统启动类,管理多个线程worker
  • WorkerApplication:某个worker管理类
  • Ant:一个实体,可用于挂载多个实体
  • Component:挂载在Ant的组件,组件可以嵌套

RPC

  • client
    export default {
        hooks:{
            async start()
            {
                console.log("ant.start",this.$ant.template)
    
                this.server = await this.$ant.spawn("rpc-server", {
                    props: {
                        name: "server"
                    }
                })
    
                const back = await this.$ant.call(this.server, "echo", "hello")
    
                console.log("get back", back)
            },
            stop()
            {
                console.log("ant.stop",this.$ant.template)
            }
        },
    }
  • server
    export default {
        props: {
            name: "unknown name"
        },
        hooks: {
            async start()
            {
                console.log("this is", this.name)
            }
        },
        remotes: {
            echo(from)
            {
                return from + " world"
            }
        }
    }

设计大纲

设计大纲

queen-core's People

Contributors

banknight avatar

Watchers

 avatar  avatar

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.