Giter VIP home page Giter VIP logo

skytree's Introduction

Profile

A distributed message broker base on mqtt5.0 protocol.

Broker Structure

components

Listener

A distributed listener for client connect. support TCP and WebSocket protocol.

Session

A distributed session manager for client implement by Raft.

Store

Store publish messages. Any database implement store interface. support mysql,redis,leveldb and so on.

@startuml
cloud "Broker"{
        component "Session" {
        component "SessionStore"
        component "SessionQueue"
        }
        component "Store" {
        component "MessageStore"
        component "MessageQueue"
        }
        component "Listener" {
        component "TCP"
        component "WebSocket"
        }
}
@enduml

Quick Start

Broker Handler Process

Connect Handler

sequenceDiagram

Client ->> Broker : request connect

Broker ->> Broker : check protocol & version 

alt set username or password 
Broker ->> Broker : auth username and password
else
end

alt property include auth
Broker ->> Broker : auth with auth data
end

Broker ->> Broker : set keepalive for client


alt flag clean is true 
    Broker ->> Session : clean client's session
    Broker ->> Store : clean store belong client
   
else
    Broker ->> Session : use old session or create new
    Broker ->> Store: try read unack message  or other unfinish task  
end

Broker ->> Session : store property to session

Broker -->> Client : response ack

Loading

How Client Read Store With Session

    sequenceDiagram
participant c as Client
participant store as Store
participant session asSession

c ->> store : request topics's message by last message id if exist or emtpy message id
store -->> session : return messages 

alt return zero message
    c ->> session : add once listen client's all topics's publish event
    c -->> c : block wait event trigger
    alt event trigger
        c ->> store: read event's topic's message by message id
        c -->> c : cancel block wait
    end       
end

Loading

Store Structure

 classDiagram
    class Packet
      Packet: GetID() string
      Packet: GetPayload() []byte
      Packet: GetOffset() int64
    class Session
    Session: NextPacket() (Packet,bool)
    Session: 
    class Message
      Message: GetOffset() int64
      Message: GetPayload() []byte
    Message --* Queue
    <<Interface>> Queue
    Queue: ReadByOffset(offset int64,limit int) []Message
    Queue: DeleteByOffset(offset int64)
 
Loading

API

skytree's People

Contributors

banice avatar ban1ce avatar

Stargazers

simon avatar Ederth avatar

Watchers

Ederth 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.