Class: GolemNetwork
golem-network/golem-network.GolemNetwork
General purpose and high-level API for the Golem Network
This class is the main entry-point for developers that would like to build on Golem Network using @golem-sdk/golem-js
. It is supposed to provide an easy access API for use 80% of use cases.
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new GolemNetwork(options?
): GolemNetwork
Parameters
Name | Type |
---|---|
options | Partial <GolemNetworkOptions > |
Returns
Defined in
src/golem-network/golem-network.ts:229
Properties
events
• Readonly
events: EventEmitter
<GolemNetworkEvents
, any
>
Defined in
src/golem-network/golem-network.ts:198
options
• Readonly
options: GolemNetworkOptions
Defined in
src/golem-network/golem-network.ts:200
market
• Readonly
market: MarketModule
Defined in
src/golem-network/golem-network.ts:206
payment
• Readonly
payment: PaymentModule
Defined in
src/golem-network/golem-network.ts:207
activity
• Readonly
activity: ActivityModule
Defined in
src/golem-network/golem-network.ts:208
network
• Readonly
network: NetworkModule
Defined in
src/golem-network/golem-network.ts:209
rental
• Readonly
rental: RentalModule
Defined in
src/golem-network/golem-network.ts:210
services
• Readonly
services: GolemServices
Dependency Container
Defined in
src/golem-network/golem-network.ts:215
Methods
connect
▸ connect(): Promise
<void
>
"Connects" to the network by initializing the underlying components required to perform operations on Golem Network
Returns
Promise
<void
>
Resolves when all initialization steps are completed
Defined in
src/golem-network/golem-network.ts:322
disconnect
▸ disconnect(): Promise
<void
>
"Disconnects" from the Golem Network
Returns
Promise
<void
>
Resolves when all shutdown steps are completed
Defined in
src/golem-network/golem-network.ts:358
oneOf
▸ oneOf(options
): Promise
<ResourceRental
>
Define your computational resource demand and access a single instance
Use Case: Get a single instance of a resource from the market to execute operations on
Parameters
Name | Type |
---|---|
options | OneOfOptions |
Returns
Promise
<ResourceRental
>
Example
const rental = await glm.oneOf({ order });
await rental
.getExeUnit()
.then((exe) => exe.run("echo Hello, Golem! 👋"))
.then((res) => console.log(res.stdout));
await rental.stopAndFinalize();
Defined in
src/golem-network/golem-network.ts:425
manyOf
▸ manyOf(options
): Promise
<ResourceRentalPool
>
Define your computational resource demand and access a pool of instances. The pool will grow up to the specified poolSize.
Parameters
Name | Type |
---|---|
options | ManyOfOptions |
Returns
Promise
<ResourceRentalPool
>
Example
// create a pool that can grow up to 3 rentals at the same time
const pool = await glm.manyOf({
poolSize: 3,
demand
});
await Promise.allSettled([
pool.withRental(async (rental) =>
rental
.getExeUnit()
.then((exe) => exe.run("echo Hello, Golem from the first machine! 👋"))
.then((res) => console.log(res.stdout)),
),
pool.withRental(async (rental) =>
rental
.getExeUnit()
.then((exe) => exe.run("echo Hello, Golem from the second machine! 👋"))
.then((res) => console.log(res.stdout)),
),
pool.withRental(async (rental) =>
rental
.getExeUnit()
.then((exe) => exe.run("echo Hello, Golem from the third machine! 👋"))
.then((res) => console.log(res.stdout)),
),
]);
Defined in
src/golem-network/golem-network.ts:548
isConnected
▸ isConnected(): boolean
Returns
boolean
Defined in
src/golem-network/golem-network.ts:621
createNetwork
▸ createNetwork(options?
): Promise
<Network
>
Creates a new logical network within the Golem VPN infrastructure. Allows communication between network nodes using standard network mechanisms, but requires specific implementation in the ExeUnit/runtime, which must be capable of providing a standard Unix-socket interface to their payloads and marshaling the logical network traffic through the Golem Net transport layer
Parameters
Name | Type |
---|---|
options? | NetworkOptions |
Returns
Promise
<Network
>
Defined in
src/golem-network/golem-network.ts:633
destroyNetwork
▸ destroyNetwork(network
): Promise
<void
>
Removes an existing network from the Golem VPN infrastructure.
Parameters
Name | Type |
---|---|
network | Network |
Returns
Promise
<void
>