Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions broker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,39 +66,39 @@ Note that for all modes, the broker attaches Directory information about the sup

Configuration is provided via environment variables:

| Name | Description | Default value |
|--------------------------|---------------------------------------------------------------------------------------|-------------------------------------------|
| `HTTP_PORT` | Server port | `8081` |
| `DB_TYPE` | Database type | `postgres` |
| `DB_USER` | Database user | `crosslink` |
| `DB_PASSWORD` | Database password | `crosslink` |
| `DB_HOST` | Database host | `localhost` |
| `DB_DATABASE` | Database name | `crosslink` |
| `DB_PORT` | Database port | `25432` |
| `LOG_LEVEL` | Log level: `ERROR`, `WARN`, `INFO`, `DEBUG` | `INFO` |
| `ENABLE_JSON_LOG` | Should JSON log format be enabled | `false` |
| `BROKER_MODE` | Default broker mode if not configured for a peer: `opaque` or `transparent` | `opaque` |
| `BROKER_SYMBOL` | Symbol for the broker when in the `opaque` mode | `ISIL:BROKER` |
| `REQ_AGENCY_INFO` | Should `request/requestingAgencyInfo` be populated from Directory | `true` |
| `SUPPLIER_INFO` | Should `request/supplierInfo` be populated from Directory | `true` |
| `RETURN_INFO` | Should `returnInfo` be populated from Directory for supplier `Loaned` message | `true` |
| `VENDOR_NOTE` | Should `note` field be prepended with `Vendor: {vendor}` text | `true` |
| `SUPPLIER_SYMBOL_NOTE` | Should `note` field be prepended with a `Supplier: {symbol}` text, `opaque` mode only | `true` |
| `OFFERED_COSTS` | Should `deliveryCosts` be transferred to `offeredCosts` for ReShare vendor requesters | `false` |
| `NOTE_FIELD_SEP` | Separator for fields (e.g. Vendor) prepended to the note | `, ` |
| `CLIENT_DELAY` | Delay duration for outgoing ISO18626 messages | `0ms` |
| `SHUTDOWN_DELAY` | Delay duration for graceful shutdown (in-flight connections) | `15s` |
| `MAX_MESSAGE_SIZE` | Max accepted ISO18626 message size | `100KB` |
| `HOLDINGS_ADAPTER` | Holdings lookup method: `mock` or `sru` | `mock` |
| `SRU_URL` | Comma separated list of URLs when `HOLDINGS_ADAPTER` is `sru` | `http://localhost:8081/sru` |
| `DIRECTORY_ADAPTER` | Directory lookup method: `mock` or `api` | `mock` |
| `DIRECTORY_API_URL` | Comma separated list of URLs when `DIRECTORY_ADAPTER` is `api` | `http://localhost:8081/directory/entries` |
| `PEER_REFRESH_INTERVAL` | Peer refresh interval (via Directory lookup) | `5m` |
| `MOCK_CLIENT_URL` | Mocked peer URLs value when `DIRECTORY_ADAPTER` is `mock` | `http://localhost:19083/iso18626` |
| `API_PAGE_SIZE` | Default value for the `limit` query parameter when paging the API | `10` |
| `TENANT_TO_SYMBOL` | Pattern to map tenant to `requesterSymbol` when accessing the API via Okapi, | (empty value) |
| | the `{tenant}` token is replaced by the `X-Okapi-Tenant` header value | |
| `SUPPLIER_PATRON_PATTERN`| Pattern used to create patron ID when receiving Request on supplier side | `%v_user` |
| Name | Description | Default value |
|---------------------------|---------------------------------------------------------------------------------------|-------------------------------------------|
| `HTTP_PORT` | Server port | `8081` |
| `DB_TYPE` | Database type | `postgres` |
| `DB_USER` | Database user | `crosslink` |
| `DB_PASSWORD` | Database password | `crosslink` |
| `DB_HOST` | Database host | `localhost` |
| `DB_DATABASE` | Database name | `crosslink` |
| `DB_PORT` | Database port | `25432` |
| `LOG_LEVEL` | Log level: `ERROR`, `WARN`, `INFO`, `DEBUG` | `INFO` |
| `ENABLE_JSON_LOG` | Should JSON log format be enabled | `false` |
| `BROKER_MODE` | Default broker mode if not configured for a peer: `opaque` or `transparent` | `opaque` |
| `BROKER_SYMBOL` | Symbol for the broker when in the `opaque` mode | `ISIL:BROKER` |
| `REQ_AGENCY_INFO` | Should `request/requestingAgencyInfo` be populated from Directory | `true` |
| `SUPPLIER_INFO` | Should `request/supplierInfo` be populated from Directory | `true` |
| `RETURN_INFO` | Should `returnInfo` be populated from Directory for supplier `Loaned` message | `true` |
| `VENDOR_NOTE` | Should `note` field be prepended with `Vendor: {vendor}` text | `true` |
| `SUPPLIER_SYMBOL_NOTE` | Should `note` field be prepended with a `Supplier: {symbol}` text, `opaque` mode only | `true` |
| `OFFERED_COSTS` | Should `deliveryCosts` be transferred to `offeredCosts` for ReShare vendor requesters | `false` |
| `NOTE_FIELD_SEP` | Separator for fields (e.g. Vendor) prepended to the note | `, ` |
| `CLIENT_DELAY` | Delay duration for outgoing ISO18626 messages | `0ms` |
| `SHUTDOWN_DELAY` | Delay duration for graceful shutdown (in-flight connections) | `15s` |
| `MAX_MESSAGE_SIZE` | Max accepted ISO18626 message size | `100KB` |
| `HOLDINGS_ADAPTER` | Holdings lookup method: `mock` or `sru` | `mock` |
| `SRU_URL` | Comma separated list of URLs when `HOLDINGS_ADAPTER` is `sru` | `http://localhost:8081/sru` |
| `DIRECTORY_ADAPTER` | Directory lookup method: `mock` or `api` | `mock` |
| `DIRECTORY_API_URL` | Comma separated list of URLs when `DIRECTORY_ADAPTER` is `api` | `http://localhost:8081/directory/entries` |
| `PEER_REFRESH_INTERVAL` | Peer refresh interval (via Directory lookup) | `5m` |
| `MOCK_CLIENT_URL` | Mocked peer URLs value when `DIRECTORY_ADAPTER` is `mock` | `http://localhost:19083/iso18626` |
| `API_PAGE_SIZE` | Default value for the `limit` query parameter when paging the API | `10` |
| `TENANT_TO_SYMBOL` | Pattern to map tenant to `requesterSymbol` when accessing the API via Okapi, | (empty value) |
| | the `{tenant}` token is replaced by the `X-Okapi-Tenant` header value | |
| `SUPPLIER_PATRON_PATTERN` | Pattern used to create patron ID when receiving Request on supplier side | `%v_user` |

# Build

Expand Down
14 changes: 7 additions & 7 deletions broker/api/api-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,12 @@ func (a *ApiHandler) PostPeers(w http.ResponseWriter, r *http.Request) {
addInternalError(ctx, w, err)
return
}
_, err = a.illRepo.GetPeerById(ctx, newPeer.ID)
_, err = a.illRepo.GetPeerById(ctx, newPeer.Id)
if err != nil && !errors.Is(err, pgx.ErrNoRows) {
addInternalError(ctx, w, err)
return
} else if err == nil {
addBadRequestError(ctx, w, fmt.Errorf("ID %v is already used", newPeer.ID))
addBadRequestError(ctx, w, fmt.Errorf("ID %v is already used", newPeer.Id))
return
}
for _, s := range newPeer.Symbols {
Expand Down Expand Up @@ -668,7 +668,7 @@ func addNotFoundError(w http.ResponseWriter) {

func toApiEvent(event events.Event) oapi.Event {
api := oapi.Event{
ID: event.ID,
Id: event.ID,
Timestamp: event.Timestamp.Time,
IllTransactionID: event.IllTransactionID,
EventType: string(event.EventType),
Expand All @@ -685,7 +685,7 @@ func toApiEvent(event events.Event) oapi.Event {

func toApiLocatedSupplier(r *http.Request, sup ill_db.LocatedSupplier) oapi.LocatedSupplier {
return oapi.LocatedSupplier{
ID: sup.ID,
Id: sup.ID,
IllTransactionID: sup.IllTransactionID,
SupplierID: sup.SupplierID,
SupplierSymbol: sup.SupplierSymbol,
Expand All @@ -705,7 +705,7 @@ func toApiLocatedSupplier(r *http.Request, sup ill_db.LocatedSupplier) oapi.Loca

func toApiIllTransaction(r *http.Request, trans ill_db.IllTransaction) oapi.IllTransaction {
api := oapi.IllTransaction{
ID: trans.ID,
Id: trans.ID,
Timestamp: trans.Timestamp.Time,
}
api.RequesterSymbol = getString(trans.RequesterSymbol)
Expand Down Expand Up @@ -761,7 +761,7 @@ func toApiPeer(peer ill_db.Peer, symbols []ill_db.Symbol, branchSymbols []ill_db
}

return oapi.Peer{
ID: peer.ID,
Id: peer.ID,
Symbols: list,
Name: peer.Name,
Url: peer.Url,
Expand Down Expand Up @@ -811,7 +811,7 @@ func toDbPeer(peer oapi.Peer) ill_db.Peer {
httpHeaders = *peer.HttpHeaders
}
db := ill_db.Peer{
ID: peer.ID,
ID: peer.Id,
Name: peer.Name,
Url: peer.Url,
Vendor: peer.Vendor,
Expand Down
1 change: 1 addition & 0 deletions broker/migrations/016_add_option_for_hrid.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP FUNCTION get_next_hrid;
6 changes: 6 additions & 0 deletions broker/migrations/016_add_option_for_hrid.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE OR REPLACE FUNCTION get_next_hrid(prefix text) RETURNS varchar AS $$
BEGIN
EXECUTE format('CREATE SEQUENCE IF NOT EXISTS %I START 1', LOWER(prefix) || '_hrid_seq');
RETURN UPPER(prefix) || '-' || nextval(LOWER(prefix) || '_hrid_seq')::TEXT;
END;
$$ LANGUAGE plpgsql;
Loading
Loading