yajsapi - JavaScript high-level API
Yagna Contributor Guide

Class: DemandBuilder

yajsapi / Exports / props/builder / DemandBuilder

Class: DemandBuilder

props/builder.DemandBuilder

Builds an object of properties and constraints from high-level models.

description The object represents a Demand object, which is later matched by the new Golem's market implementation against Offers coming from providers to find those providers who can satisfy the requestor's demand.

example

import dayjs from "dayjs"
import { props } from "yajsapi"
dayjs.extend(utc);
const { Activity, DemandBuilder, NodeInfo } = props;
let builder = new DemandBuilder();
builder.add(NodeInfo("testnet", "a node"));
let act = new yp.Activity();
act.expiration.value = dayjs().utc().unix() * 1000;
builder.add(act);
console.log(builder);
// Output:
// {'properties':
// {'golem.node.id.name': 'a node',
// 'golem.node.debug.subnet': 'testnet',
// 'golem.srv.comp.expiration': 1601655628772},
// 'constraints': []}

Hierarchy

  • DemandBuilder

Table of contents

Constructors

Properties

Methods

Constructors

constructor

Returns: DemandBuilder

Defined in: yajsapi/props/builder.ts:35

Properties

_constraints

_constraints: string[]

Defined in: yajsapi/props/builder.ts:35

_properties

_properties: Object

Defined in: yajsapi/props/builder.ts:34

Methods

add

add(m: any): void

Parameters:

Name

Type

m

any

Returns: void

Defined in: yajsapi/props/builder.ts:66

constraints

constraints(): string

Returns: string

Defined in: yajsapi/props/builder.ts:47

ensure

ensure(constraint: string): void

Parameters:

Name

Type

constraint

string

Returns: void

Defined in: yajsapi/props/builder.ts:61

properties

properties(): object

Returns: object

Defined in: yajsapi/props/builder.ts:42

subscribe

subscribe(market: Market): Promise<Subscription>

Parameters:

Name

Type

market

Market

Returns: Promise<Subscription>

Defined in: yajsapi/props/builder.ts:90