sip2

package
v0.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sip2 is a client for the 3M Standard Interchange Protocol version 2 (SIP2), the request/response protocol integrated library systems speak for real-time circulation. It implements the discovery slice: an optional Login (93/94) and Item Information (17/18) over a TCP session, for asking an ILS "is this item on the shelf?" It does not cover checkout, holds, fees or patron messages.

A session is strictly request/response and a Conn is not safe for concurrent use. The wire format is line-oriented: a two-digit command code, fixed-length fields, then pipe-delimited variable fields, terminated by a carriage return, with an optional trailing AY/AZ error-detection checksum.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CirculationStatusLabel

func CirculationStatusLabel(code string) string

CirculationStatusLabel returns the human-readable meaning of a SIP2 circulation status code, or "" for an unrecognized code.

Types

type Client

type Client struct {
	Address string // host:port of the SIP2 server (the ACS)

	// Login (93) is sent only when User is non-empty: CN=User, CO=Password, and
	// CP=Location when set. Both algorithm bytes are the plain "0".
	User     string
	Password string
	Location string // login location code (CP); optional

	// InstitutionID (AO) and TerminalPass (AC) ride on each Item Information
	// request; both optional, sent as empty fields when unset.
	InstitutionID string
	TerminalPass  string

	// ErrorDetection appends the AY sequence and AZ checksum to each outbound
	// message. Inbound AY/AZ are always tolerated and skipped regardless.
	ErrorDetection bool

	// Dial is the connection seam, overridable in tests. When nil a plain TCP
	// dialer bound to the request context is used.
	Dial func(ctx context.Context, addr string) (net.Conn, error)
}

Client holds the SIP2 target and session defaults. The zero value needs at least Address set; construct one with NewClient.

func NewClient

func NewClient(addr string) *Client

NewClient returns a Client for a host:port SIP2 target.

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) (*Conn, error)

Connect dials the target and, when a User is configured, performs the Login (93/94) exchange. Close the Conn when done.

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn is one SIP2 session over a live connection. Not safe for concurrent use.

func (*Conn) Close

func (co *Conn) Close() error

Close ends the session by closing the underlying connection. SIP2 has no mandatory logout for the item-information slice.

func (*Conn) ItemInformation

func (co *Conn) ItemInformation(ctx context.Context, itemID string) (*ItemInfo, error)

ItemInformation requests circulation status for one item barcode (17) and parses the response (18).

type ItemInfo

type ItemInfo struct {
	CirculationStatus string // 2-digit code, 01-13 (see CirculationStatusLabel)
	StatusLabel       string // human meaning of CirculationStatus
	SecurityMarker    string // 2-digit security marker
	FeeType           string // 2-digit fee type
	TransactionDate   string // 18-char SIP2 date

	ItemID            string // AB
	Title             string // AJ
	DueDate           string // AH
	CurrentLocation   string // AP
	PermanentLocation string // AQ
	CallNumber        string // CS (3M extension)
	HoldQueueLength   string // CF

	Fields map[string]string // all variable fields by 2-char code
}

ItemInfo is a parsed Item Information Response (18): the fixed status header and the variable fields a discovery caller reads. Fields holds every variable field (first occurrence) for anything not surfaced as a named member.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL