Skip to content

chore: move more of the stream implementation from the root-level gorums package to the stream package #268

@meling

Description

@meling

Move Channel and Server Logic to internal/stream

The goal is to move channel.go and parts of server.go to internal/stream to co-locate related logic.

Proposed Changes

NEW: internal/stream/channel.go

  • Move content of gorums/channel.go here.
  • Rename channel -> Channel (Exported).
  • Rename newChannel -> NewChannel (Exported).
  • Rename request -> Request (Exported).
  • Rename nodeClosedErr -> ErrNodeClosed (Exported).
  • Rename streamDownErr -> ErrStreamDown (Exported).

NEW:response.go

  • Move NodeResponse definition here.
  • Move ErrTypeMismatch here (or to errors.go in stream).

NEW: marshaling.go

  • Move unmarshalRequest -> UnmarshalRequest.
  • Move unmarshalResponse -> UnmarshalResponse.

MOD: gorums/channel.go: DELETE the file.

MOD: node.go

  • Update channel field in Node to *stream.Channel.
  • Update newNode to call stream.NewChannel.
  • Update NodeContext.enqueue to use stream.Request.

MOD: encoding.go

  • Remove unmarshalRequest and unmarshalResponse.
  • Update usages to stream.UnmarshalRequest / stream.UnmarshalResponse if needed (unlikely if they are only used by channel/server).

MOD: errors.go

  • Remove ErrTypeMismatch.
  • Add alias: var ErrTypeMismatch = stream.ErrTypeMismatch (or just re-export/define).

KEEP: server.go for now

  • streamServer is harder to move due to Handler dependency.
  • Option 1: Keep streamServer in gorums for now (Simpler).
  • Option 2: Define stream.Handler interface and move streamServer to stream.Server.
    I recommend Option 1 for the first pass to ensure stability, then tackle server in a second pass.

Sub-issues

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions