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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]

### Added
* Added Go language binding. ([#1483](https://github.com/finos/FDC3/pull/1483))

### Changed

Expand Down
164 changes: 164 additions & 0 deletions website/docs/api/ref/Channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,36 @@ interface IChannel: IIntentResult
}
```

</TabItem>
<TabItem value="golang" label="Go">

```go
@experimental
type IChannel interface {
Broadcast(context Context) <-chan Result[any]
GetCurrentContext(contextType string) <-chan Result[IContext]
AddContextListener(contextType string, handler ContextHandler) <-chan Result[Listener]
}

@experimental
type Channel struct {
Id string `json:"id"`
Type ChannelType `json:"type"`
DisplayMetadata *DisplayMetadata `json:"displayMetadata"`
}

@experimental
type ChannelType string

@experimental
const (
App ChannelType = "app"
Private ChannelType = "private"
User ChannelType = "user"
System ChannelType = "system"
)
```

</TabItem>
</Tabs>

Expand Down Expand Up @@ -89,6 +119,13 @@ public readonly id: string;
string Id { get; }
```

</TabItem>
<TabItem value="golang" label="Go">

```go
Id string
```

</TabItem>
</Tabs>

Expand Down Expand Up @@ -117,6 +154,18 @@ public enum ChannelType
}
```

</TabItem>
<TabItem value="golang" label="Go">

```go
type ChannelType string

const (
App ChannelType = "app"
System ChannelType = "system"
Private ChannelType = "private"
)
```
</TabItem>
</Tabs>

Expand All @@ -138,6 +187,12 @@ public readonly displayMetadata?: DisplayMetadata;
IDisplayMetadata? DisplayMetadata { get; }
```

</TabItem>
<TabItem value="golang" label="Go">

```go
DisplayMetadata *DisplayMetadata
```
</TabItem>
</Tabs>

Expand Down Expand Up @@ -165,6 +220,15 @@ public addContextListener(contextType: string | null, handler: ContextHandler):
Task<IListener> AddContextListener<T>(string? contextType, ContextHandler<T> handler) where T : IContext;
```

</TabItem>
<TabItem value="golang" label="Go">

```go
func (ch *Channel) AddContextListener(contextType string, handler ContextHandler) <-chan Result[Listener] {
// Implementation here
}
```

</TabItem>
</Tabs>

Expand Down Expand Up @@ -213,6 +277,26 @@ var listener = await channel.AddContextListener<IContext>(null, (context, metada
listener.Unsubscribe();
```

</TabItem>
<TabItem value="golang" label="Go">

```go
listenerResult := <-channel.AddContextListener("", func(contextInt IContext, contextMetadata *ContextMetadata) {
if context, ok := contextInt.(Context); ok {
if context.Type == "fdc3.contact" {
// handle the contact
} else if context.Type == "fdc3.instrument" {
// handle the instrument
}
}
})

// later
if listenerResult.Value != nil {
listenerResult.Value.Unsubscribe()
}
```

</TabItem>
</Tabs>

Expand Down Expand Up @@ -252,6 +336,26 @@ contactListener.unsubscribe();
instrumentListener.unsubscribe();
```

</TabItem>
<TabItem value="golang" label="Go">

```go
listenerResultContact := <-channel.AddContextListener("fdc3.contact", func(context IContext, contextMetadata *ContextMetadata) {
// handle the contact
})
listenerResultInstrument := <-channel.AddContextListener("fdc3.instrument", func(context IContext, contextMetadata *ContextMetadata) {
// handle the instrument
})

// later
if listenerResultContact.Value != nil {
listenerResultContact.Value.Unsubscribe()
}
if listenerResultInstrument.Value != nil {
listenerResultInstrument.Value.Unsubscribe()
}
```

</TabItem>
</Tabs>

Expand All @@ -278,6 +382,15 @@ public broadcast(context: Context): Promise<void>;
Task Broadcast(IContext context);
```

</TabItem>
<TabItem value="golang" label="Go">

```go
func (channel *Channel) Broadcast(context IContext) <-chan Result[any] {
// Implementation here
}
```

</TabItem>
</Tabs>

Expand Down Expand Up @@ -327,6 +440,21 @@ catch (Exception ex)
}
```

</TabItem>
<TabItem value="golang" label="Go">

```go
result := <-myChannel.Broadcast(types.Context{
Type: "fdc3.instrument",
Id: map[string]string{
"ticker": "AAPL",
},
})
if result.Err != null {
// handle error
}
```

</TabItem>
</Tabs>

Expand All @@ -352,6 +480,15 @@ public getCurrentContext(contextType?: string): Promise<Context|null>;
Task<IContext?> GetCurrentContext(string? contextType);
```

</TabItem>
<TabItem value="golang" label="Go">

```go
func (channel *Channel) GetCurrentContext(contextType string) <-chan Result[Context] {
// Implementation here
}
```

</TabItem>
</Tabs>

Expand Down Expand Up @@ -392,6 +529,16 @@ catch (Exception ex)
}
```

</TabItem>
<TabItem value="golang" label="Go">

```go
result := <-myChannel.GetCurrentContext("")
if result.Err != null {
// handle error
}
```

</TabItem>
</Tabs>

Expand Down Expand Up @@ -422,6 +569,16 @@ catch (Exception ex)
}
```

</TabItem>
<TabItem value="golang" label="Go">

```go
result := <-myChannel.GetCurrentContext("fdc3.contact")
if result.Err != null {
// handle error
}
```

</TabItem>
</Tabs>

Expand Down Expand Up @@ -452,6 +609,13 @@ public addContextListener(handler: ContextHandler): Promise<Listener>;
Not implemented
```

</TabItem>
<TabItem value="golang" label="Go">

```
Not implemented
```

</TabItem>

</Tabs>
Expand Down
Loading
Loading