G
G
Golem SDK
Search…
yapapi - Python high-level API
yajsapi - JavaScript high-level API
Classes
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
1
import dayjs from "dayjs"
2
import { props } from "yajsapi"
3
4
dayjs.extend(utc);
5
6
const { Activity, DemandBuilder, NodeInfo } = props;
7
let builder = new DemandBuilder();
8
builder.add(NodeInfo("testnet", "a node"));
9
let act = new yp.Activity();
10
act.expiration.value = dayjs().utc().unix() * 1000;
11
builder.add(act);
12
console.log(builder);
13
// Output:
14
// {'properties':
15
// {'golem.node.id.name': 'a node',
16
// 'golem.node.debug.subnet': 'testnet',
17
// 'golem.srv.comp.expiration': 1601655628772},
18
// 'constraints': []}
Copied!

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new DemandBuilder()
Defined in

Properties

_constraints

_constraints: string[]
Defined in

_properties

_properties: Object
Defined in

Methods

add

add(m): void
Parameters
Name
Type
m
any
Returns
void
Defined in

constraints

constraints(): string
Returns
string
Defined in

ensure

ensure(constraint): void
Parameters
Name
Type
constraint
string
Returns
void
Defined in

properties

properties(): object
Returns
object
Defined in

subscribe

subscribe(market): Promise<Subscription>
Parameters
Name
Type
market
Market
Returns
Promise<Subscription>
Defined in