Skip to content

cuprated as a library #554

@hinto-janai

Description

@hinto-janai

What

Initial implementation and type/signature proposal for cuprated as a library.

#516.

Where

binaries/cuprated could be a double binary/library.

Another option is binaries/cuprated could be turned into a thin shell around a new library that contains the core node functionality, perhaps this would be cleaner.

Library name/location: TODO.

How

Some changes/fixes are necessary as binaries/cuprated currently assumes it is a standalone binary e.g.:

  • Many types/signatures are pub
  • Global rayon, tokio, tracing usage; these will panic when initialized elsewhere
  • CLI handling is intermixed with the config code, this must be separated

API (wip)

//! # `cuprated` library.

/// An active `cuprated` node.
///
/// `Drop` will end the node process.
pub struct Node {/* ... */}

pub struct NodeConfig {/* ... */}
pub struct NodeEventListener {/* ... */}

impl Node {
    /// Launch a new `cuprated` process.
    pub fn launch(conifg: NodeConfig) -> Result<Self, Error>;

    /// `Stream` of events emitted by `cuprated`.
    pub fn events(&self) -> NodeEventListener;

    /// Current config in use.
    pub fn config(&self) -> &NodeConfig;
}

pub mod statics {
    /* `binaries/cuprated/src/statics.rs` could be moved here */
}

pub mod signals {
    /* `binaries/cuprated/src/signals.rs` could be moved here */
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-binariesArea: Related to binaries.C-proposalCategory: A proposal of some kind, and a request for comments.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions