b

package
v0.0.0-...-ec15cf2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BlueprintAlice = MustValidate(Blueprint{
	Name: "alice",
	Homeservers: []Homeserver{
		{
			Name: "hs1",
			Users: []User{
				{
					Localpart:   "@alice",
					DisplayName: "Alice",
				},
			},
		},
	},
})

BlueprintAlice is a single user homeserver

View Source
var BlueprintCleanHS = MustValidate(Blueprint{
	Name: "clean_hs",
	Homeservers: []Homeserver{
		{
			Name: "hs1",
		},
	},
})

BlueprintCleanHS is a clean homeserver with no rooms or users

View Source
var BlueprintFederationOneToOneRoom = MustValidate(Blueprint{
	Name: "federation_one_to_one_room",
	Homeservers: []Homeserver{
		{
			Name: "hs1",
			Users: []User{
				{
					Localpart:   "@alice",
					DisplayName: "Alice",
				},
			},
			Rooms: []Room{
				{
					CreateRoom: map[string]interface{}{
						"preset": "public_chat",
					},
					Creator: "@alice",
					Ref:     "alice_room",
					Events: []Event{
						{
							Type: "m.room.message",
							Content: map[string]interface{}{
								"body":    "Hello world",
								"msgtype": "m.text",
							},
							Sender: "@alice",
						},
					},
				},
			},
		},
		{
			Name: "hs2",
			Users: []User{
				{
					Localpart:   "@bob",
					DisplayName: "Bob",
				},
			},
			Rooms: []Room{
				{
					Ref: "alice_room",
					Events: []Event{
						{
							Type:     "m.room.member",
							StateKey: Ptr("@bob:hs2"),
							Content: map[string]interface{}{
								"membership": "join",
							},
							Sender: "@bob",
						},
						{
							Type: "m.room.message",
							Content: map[string]interface{}{
								"body":    "Hello world2",
								"msgtype": "m.text",
							},
							Sender: "@bob",
						},
					},
				},
			},
		},
	},
})

BlueprintFederationOneToOneRoom contains two homeservers with 1 user in each, who are joined to the same room.

View Source
var BlueprintFederationTwoLocalOneRemote = MustValidate(Blueprint{
	Name: "federation_two_local_one_remote",
	Homeservers: []Homeserver{
		{
			Name: "hs1",
			Users: []User{
				{
					Localpart:   "@alice",
					DisplayName: "Alice",
				},
				{
					Localpart:   "@bob",
					DisplayName: "Bob",
				},
			},
		},
		{
			Name: "hs2",
			Users: []User{
				{
					Localpart:   "@charlie",
					DisplayName: "Charlie",
				},
			},
		},
	},
})

BlueprintFederationTwoLocalOneRemote is a two-user homeserver federating with a one-user homeserver

View Source
var BlueprintHSWithApplicationService = MustValidate(Blueprint{
	Name: "hs_with_application_service",
	Homeservers: []Homeserver{
		{
			Name: "hs1",
			Users: []User{
				{
					Localpart:   "@alice",
					DisplayName: "Alice",
				},
				{
					Localpart:   "@bob",
					DisplayName: "Bob",
				},
			},
			ApplicationServices: []ApplicationService{
				{
					ID:              "my_as_id",
					URL:             "http://localhost:9000",
					SenderLocalpart: "the-bridge-user",
					RateLimited:     false,
				},
			},
		},
		{
			Name: "hs2",
			Users: []User{
				{
					Localpart:   "@charlie",
					DisplayName: "Charlie",
				},
			},
		},
	},
})

BlueprintHSWithApplicationService who has an application service to interact with

View Source
var BlueprintOneToOneRoom = MustValidate(Blueprint{
	Name: "one_to_one_room",
	Homeservers: []Homeserver{
		{
			Name: "hs1",
			Users: []User{
				{
					Localpart:   "@alice",
					DisplayName: "Alice",
				},
				{
					Localpart:   "@bob",
					DisplayName: "Bob",
				},
			},
			Rooms: []Room{
				{
					CreateRoom: map[string]interface{}{
						"preset": "public_chat",
					},
					Creator: "@alice",
					Events: []Event{
						{
							Type:     "m.room.member",
							StateKey: Ptr("@bob:hs1"),
							Content: map[string]interface{}{
								"membership": "join",
							},
							Sender: "@bob",
						},
						{
							Type: "m.room.message",
							Content: map[string]interface{}{
								"body":    "Hello world",
								"msgtype": "m.text",
							},
							Sender: "@bob",
						},
					},
				},
			},
		},
	},
})

BlueprintOneToOneRoom contains a homeserver with 2 users, who are joined to the same room.

View Source
var BlueprintPerfManyMessages = MustValidate(Blueprint{
	Name: "perf_many_messages",
	Homeservers: []Homeserver{
		{
			Name: "hs1",
			Users: []User{
				{
					Localpart:   "@alice",
					DisplayName: "Alice",
				},
				{
					Localpart:   "@bob",
					DisplayName: "Bob",
				},
			},
			Rooms: []Room{
				{
					CreateRoom: map[string]interface{}{
						"preset": "public_chat",
					},
					Creator: "@alice",
					Events: append([]Event{
						Event{
							Type:     "m.room.member",
							StateKey: Ptr("@bob:hs1"),
							Content: map[string]interface{}{
								"membership": "join",
							},
							Sender: "@bob",
						},
					}, manyMessages([]string{"@alice", "@bob"}, 7000)...),
				},
			},
		},
	},
})

BlueprintPerfManyMessages contains a homeserver with 2 users, who are joined to the same room with thousands of messages.

View Source
var BlueprintPerfManyRooms = MustValidate(Blueprint{
	Name: "perf_many_rooms",
	Homeservers: []Homeserver{
		{
			Name: "hs1",
			Users: []User{
				{
					Localpart:   "@alice",
					DisplayName: "Alice",
				},
				{
					Localpart:   "@bob",
					DisplayName: "Bob",
				},
			},
			Rooms: perfManyRooms([]string{"@alice", "@bob"}, 400),
		},
	},
})

BlueprintPerfManyRooms contains a homeserver with 2 users, who are joined to hundreds of rooms with a few messages in each.

KnownBlueprints lists static blueprints

Functions

func Ptr

func Ptr(in string) *string

Ptr returns a pointer to `in`, because Go doesn't allow you to inline this.

Types

type AccountData

type AccountData struct {
	Type  string
	Value map[string]interface{}
}

type ApplicationService

type ApplicationService struct {
	ID               string
	HSToken          string
	ASToken          string
	URL              string
	SenderLocalpart  string
	RateLimited      bool
	SendEphemeral    bool
	EnableEncryption bool
}

type Blueprint

type Blueprint struct {
	// The name of the blueprint. Containers will use this name.
	Name string
	// The list of homeservers to create for this deployment.
	Homeservers []Homeserver
	// A set of user IDs to retain access_tokens for. If empty, all tokens are kept.
	KeepAccessTokensForUsers []string
}

Blueprint represents an entire deployment to make.

func MustValidate

func MustValidate(bp Blueprint) Blueprint

func Validate

func Validate(bp Blueprint) (Blueprint, error)

type Event

type Event struct {
	Type     string                 `json:"type"`
	Sender   string                 `json:"sender,omitempty"`
	StateKey *string                `json:"state_key,omitempty"`
	Content  map[string]interface{} `json:"content"`
}

type Homeserver

type Homeserver struct {
	// The name of this homeserver. Containers will use this name.
	Name string
	// The list of users to create on this homeserver.
	Users []User
	// The list of rooms to create on this homeserver
	Rooms []Room
	// The list of application services to create on the homeserver
	ApplicationServices []ApplicationService
	// Optionally override the baseImageURI for blueprint creation
	BaseImageURI *string
}

type Room

type Room struct {
	// The unique reference for this room. Used to link together rooms across homeservers.
	Ref        string
	Creator    string
	CreateRoom map[string]interface{}
	Events     []Event
}

type User

type User struct {
	Localpart   string
	DisplayName string
	AvatarURL   string
	AccountData []AccountData
	DeviceID    *string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL